diff --git a/guestbook-ng.pl b/guestbook-ng.pl index c466a2b..bb3200f 100755 --- a/guestbook-ng.pl +++ b/guestbook-ng.pl @@ -18,7 +18,9 @@ helper pg => sub { app->config->{'pg_user'} . ':' . app->config->{'pg_pw'} . - '@localhost/' . + '@' . + app->config->{'pg_host'} . + '/' . app->config->{'pg_db'} ); }; diff --git a/lib/GuestbookNg/Model/Test.pm b/lib/GuestbookNg/Model/Test.pm index da8dc0b..10075b3 100644 --- a/lib/GuestbookNg/Model/Test.pm +++ b/lib/GuestbookNg/Model/Test.pm @@ -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) { diff --git a/migrations/1/down.sql b/migrations/1/down.sql new file mode 100644 index 0000000..f8f44a8 --- /dev/null +++ b/migrations/1/down.sql @@ -0,0 +1 @@ +DROP TABLE messages; diff --git a/migrations/1/up.sql b/migrations/1/up.sql new file mode 100644 index 0000000..6d4e7e3 --- /dev/null +++ b/migrations/1/up.sql @@ -0,0 +1,6 @@ +CREATE TABLE IF NOT EXISTS messages ( + id SERIAL PRIMARY KEY, + date TIMESTAMPTZ, + name VARCHAR(64), + msg VARCHAR(255) +);