Created
October 1, 2011 15:17
-
-
Save monken/1256169 to your computer and use it in GitHub Desktop.
build dbic schema dynamically
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
package MySchema; | |
use Moose; | |
extends 'DBIx::Class::Schema'; | |
use Moose; | |
use DBIx::Class::ResultSource::Table; | |
my $result_class = Moose::Meta::Class->create( | |
Foo => ( superclasses => ['DBIx::Class::Core'] ) | |
); | |
my $source = DBIx::Class::ResultSource::Table->new({ | |
name => 'foo', | |
result_class => $result_class->name, | |
}); | |
$source->add_column( column1 => { data_type => 'integer' } ); | |
MySchema->register_source(foo => $source); | |
my $schema = MySchema->connect('dbi:SQLite::memory:'); | |
warn $schema->deployment_statements; | |
# -- | |
# -- Created by SQL::Translator::Producer::SQLite | |
# -- Created on Sat Oct 1 17:16:46 2011 | |
# -- | |
# | |
# BEGIN TRANSACTION-- | |
# -- Table: foo | |
# -- | |
# CREATE TABLE foo ( | |
# column1 integer NOT NULL | |
# )COMMIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment