Skip to content

Instantly share code, notes, and snippets.

@reneeb
Last active March 23, 2018 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reneeb/f35f08422a8ff3d9fc3e55a9dcb7483d to your computer and use it in GitHub Desktop.
Save reneeb/f35f08422a8ff3d9fc3e55a9dcb7483d to your computer and use it in GitHub Desktop.
./mini_crm
+- docs
| - mini_crm.mwb
+- script
- create_db.pl
- mini_crm.pl
#!/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;
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