Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.