Thai Heng has asked for the wisdom of the Perl Monks concerning the following question:

I use module Mojo::Pg::Migrations in windows, but It can't work properly. perl: v5.22.0, Mojo::Pg 2.08, Postgres: 9.4. OS:windows7 64. database postgres have only one schema named public.

use v5.22.0; use Mojo::Pg; my $pg = Mojo::Pg->new('postgresql://postgres:fengguang@localhost/post +gres'); my $result = $pg->migrations->from_file('E:\QMDownload\Mojo-Pg-2.08\ex +amples\blog\migrations\blog.sql')->migrate; say $pg->db->query('select ?::json as foo', {json => {bar => 'baz'}}) ->expand->hash->{foo}{bar};

What's wrong?

the file blog.sql as follows

-- 1 up create table if not exists posts ( id serial primary key, title text, body text ); -- 1 down drop table if exists posts;

Replies are listed 'Best First'.
Re: Mojo::Pg::Migrations can't work in windows
by 1nickt (Canon) on Aug 28, 2015 at 03:30 UTC

    The documentation suggests you should use:

    use Mojo::Pg; use Mojo::Pg::Migrations; my $dsn = 'postgresql://postgres:fengguang@localhost/postgres'; my $file = 'E:\QMDownload\Mojo-Pg-2.08\examples\blog\migrations\blog.s +ql'; my $migrations = Mojo::Pg::Migrations->new( pg => Mojo::Pg->new( $dsn +) ); $migrations = $migrations->from_file( $file )->migrate;
    The way forward always starts with a minimal test.

      Thanks!

      The true reason is there is table mojo_migrations and no table posts. The code have no differences.

        Glad you got it working. I could only guess, since you didn't post the error message :-)

        The way forward always starts with a minimal test.