i'am new for databases and DBIx: class. So please forgive me if this is a complete newbie mistake. I just went for the tutorial and then tried to deploy the schema to my database. According to the tutorial, I broke the modules in several files. After I run createTable.pl "mysqlshow bla" shows me an empty database.
Work with the database is started. Creating a table using the mysql CREATE TABLE statement works.
The script file that should create the table according to the schema .. /createTable.pl
#!/usr/bin/env perl use Modern::Perl; use MyDatabase::Main; my ($database, $user) = ('bla', 'flo'); my $schema = MyDatabase::Main->connect("dbi:mysql:dbname=$database", "$user"); $schema->deploy( { auto_drop_tables => 1 } );
Main.pm for loading namespaces. /MyDatabase/Main.pm
package MyDatabase::Main; use base qw/ DBIx::Class::Schema /; __PACKAGE__->load_namespaces(); 1;
Schema file for table .. /MyDatabase/Result/Album.pm
package MyDatabase::Main::Result::Album; use base qw/ DBIx::Class::Core /; __PACKAGE__->load_components(qw/ Ordered /); __PACKAGE__->position_column('rank'); __PACKAGE__->table('album'); __PACKAGE__->add_columns(albumid => { accessor => 'album', data_type => 'integer', size => 16, is_nullable => 0, is_auto_increment => 1, }, artist => { data_type => 'integer', size => 16, is_nullable => 0, }, title => { data_type => 'varchar', size => 256, is_nullable => 0, }, rank => { data_type => 'integer', size => 16, is_nullable => 0, default_value => 0, } ); __PACKAGE__->set_primary_key('albumid'); 1;
I have already spent several hours searching for help via google, but not much is involved with the deploy () method. Can someone explain to me that my mistake? thank you