Can DBIx :: Class be used to create tables?

I do not think I understand the scope of DBIx::Class
Should I manually create a database with plain SQL first and then use the schemaloader (or manually encode the schema / results)?
Or is there a way to tell DBIx::Class continue and create tables from a manually encoded schema and result set?
I ask b / c if I need to create a database using the SQL CREATE TABLE statement, I have a column essentially duplicated in the ResultSet code, or I need to rely on a loader block that I believe is inefficient and inappropriate for production.

+8
perl dbix-class
source share
2 answers

You can deploy() your schema:

 my $schema = MyApp::Schema->connect( $dsn, $user, $password, ); $schema->deploy( { add_drop_table => 1 } ); 

Of course, the above will lose existing tables :)

+13
source share

You can go on any route. You can create a schema and get DBIx :: Class to parse it , or you can get DBIx :: Class to build the schema for you .

The first should not be inefficient for production, since you can get DBIx :: Class to save the generated code so that it does not have to do an analysis of each run.

+10
source share

All Articles