Created
June 6, 2017 16:38
-
-
Save bimmerlabs/c86c15aec76b2efca6f5ca9109dc850d to your computer and use it in GitHub Desktop.
Mojo:PG migration - I'm having some trouble and it's because I don't quite understand what it's doing.
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 MyApp::Model::DBAdmin; | |
use Mojo::Base -base; | |
has 'database'; | |
sub new { bless {}, shift } | |
sub create_table { | |
my ($self, $tablename) = @_; | |
$tablename = "test"; | |
$self->database->migrations->name($tablename)->from_string( | |
"-- 1 up | |
create table if not exists $tablename (id serial primary key, name text); | |
-- 1 down | |
drop table if exists $tablename;" | |
)->migrate; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment