Skip to content

Instantly share code, notes, and snippets.

@bimmerlabs
Created June 6, 2017 16:38
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 bimmerlabs/c86c15aec76b2efca6f5ca9109dc850d to your computer and use it in GitHub Desktop.
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.
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