-
-
Save reneeb/f35f08422a8ff3d9fc3e55a9dcb7483d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./mini_crm | |
+- docs | |
| - mini_crm.mwb | |
+- script | |
- create_db.pl | |
- mini_crm.pl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use File::Basename; | |
use File::Spec; | |
use MySQL::Workbench::DBIC; | |
use MySQL::Workbench::SQLiteSimple; | |
my $base_dir = File::Spec->rel2abs( File::Spec->catdir( dirname( __FILE__ ), '..' ) ); | |
my $mwb_file = File::Spec->catfile( $base_dir, 'docs', 'mini_crm.mwb' ); | |
my $out_dir = File::Spec->catdir( $base_dir, 'lib' ); | |
my $foo = MySQL::Workbench::DBIC->new( | |
file => $mwb_file, | |
output_path => $out_dir, | |
namespace => 'Speakers::DB', | |
version_add => 1, | |
schema_name => 'Schema', | |
column_details => 1, # default 1 | |
uppercase => 1, | |
); | |
$foo->create_schema; | |
my $sqlite = MySQL::Workbench::SQLiteSimple->new( | |
file => $mwb_file, | |
output_path => File::Spec->catdir( $base_dir, 'docs' ), | |
); | |
$sqlite->create_sql; | |
print sprintf "Version %s of DB created\n", $foo->version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $db = '/pfad/zur/minicrm.db'; | |
$self->app->helper( db => sub { | |
Speakers::DB::Schema->connect( "DBI:SQLite:".$db ) | |
}); | |
$self->plugin('GraphQL' => { | |
convert => [ 'DBIC', sub { $self->db } ], | |
graphiql => 1, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment