Implemented migrations dir
This commit is contained in:
parent
807bdd155c
commit
c6082e095b
|
@ -18,7 +18,9 @@ helper pg => sub {
|
|||
app->config->{'pg_user'} .
|
||||
':' .
|
||||
app->config->{'pg_pw'} .
|
||||
'@localhost/' .
|
||||
'@' .
|
||||
app->config->{'pg_host'} .
|
||||
'/' .
|
||||
app->config->{'pg_db'}
|
||||
);
|
||||
};
|
||||
|
|
|
@ -15,17 +15,7 @@ sub test_model($self, $string) {
|
|||
}
|
||||
|
||||
sub create_table($self) {
|
||||
$self->pg->migrations->from_string(
|
||||
"-- 1 up
|
||||
CREATE TABLE IF NOT EXISTS messages (
|
||||
id int,
|
||||
date timestamp with time zone,
|
||||
name varchar(255),
|
||||
msg varchar(255)
|
||||
);
|
||||
-- 1 down
|
||||
DROP TABLE messages;"
|
||||
)->migrate();
|
||||
$self->pg->migrations->from_dir('migrations')->migrate(1);
|
||||
}
|
||||
|
||||
sub now($self) {
|
||||
|
|
1
migrations/1/down.sql
Normal file
1
migrations/1/down.sql
Normal file
|
@ -0,0 +1 @@
|
|||
DROP TABLE messages;
|
6
migrations/1/up.sql
Normal file
6
migrations/1/up.sql
Normal file
|
@ -0,0 +1,6 @@
|
|||
CREATE TABLE IF NOT EXISTS messages (
|
||||
id SERIAL PRIMARY KEY,
|
||||
date TIMESTAMPTZ,
|
||||
name VARCHAR(64),
|
||||
msg VARCHAR(255)
|
||||
);
|
Loading…
Reference in a new issue