Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations do not run #388

Closed
paulosuzart opened this issue Feb 7, 2018 · 6 comments
Closed

Migrations do not run #388

paulosuzart opened this issue Feb 7, 2018 · 6 comments

Comments

@paulosuzart
Copy link

paulosuzart commented Feb 7, 2018

Hi, I started to follow the tutorial and Lucky as able to create my development database (also able to drop it). Everything is fine until I generate a new migration using:

lucky gen.migration CreateUsers and then trying to apply it with lucky db.migrate I get no tables in the database.

The migration is pretty simple and the project is brand new with no other changes. Migration can be seen here https://gist.github.com/paulosuzart/eb859d41193a683df09e2091d5644a79

I'm using postgres 9.5.7 and lucky v0.9.2. Anyone facing the same?

Regards

@paulcsmith
Copy link
Member

This is the first I've heard of anyone running into this problem. Do you have a public repo I could pull down and try out?

Thanks!

@paulcsmith paulcsmith added the bug label Feb 8, 2018
@paulosuzart
Copy link
Author

Hi Paul, thanks for the quick reply. Just created a new app and uploaded to https://github.com/paulosuzart/my_blog2. The bin/setup runs without any issues and the empty database was created.

There is just one migration as simple as the official tutorial on the framework page.

This is the lucky dev output and it open the browser as expected. Bu the lucky db.migrate get no output (I'm running as a postgres super user):

➜  my_blog2 git:(master) lucky dev
[WARN] No ENV file found
16:01:32 web.1      |  Beginnning to watch your project
16:01:32 web.1      |  compiling...
16:01:32 assets.1   |  yarn run v1.3.2
16:01:32 assets.1   |  $ /data/roundlabs/my_blog2/node_modules/.bin/brunch watch
16:01:36 assets.1   |  16:01:36 - info: compiled 6 files into 2 files in 3.8 sec
16:01:37 web.1      |  Listening on http://0.0.0.0:5000
16:01:37 web.1      |  yarn run v1.3.2
16:01:37 web.1      |  $ /data/roundlabs/my_blog2/node_modules/.bin/browser-sync start -c bs-config.js --port 3001 -p http://0.0.0.0:5000
16:01:38 web.1      |  [Browsersync] Proxying: http://0.0.0.0:5000
16:01:38 web.1      |  [Browsersync] Access URLs:
16:01:38 web.1      |   -------------------------------------
16:01:38 web.1      |         Local: http://localhost:3001
16:01:38 web.1      |      External: http://192.168.1.58:3001
16:01:38 web.1      |   -------------------------------------
16:01:38 web.1      |            UI: http://localhost:3002
16:01:38 web.1      |   UI External: http://192.168.1.58:3002
16:01:38 web.1      |   -------------------------------------
16:01:38 web.1      |  [Browsersync] Watching files...
16:01:39 web.1      |  GET 200 / (675.0µs)
16:01:39 web.1      |    ▸ Handled by Home::Index
16:01:39 web.1      |    ▸ Rendered Lucky::WelcomePage

Here the postgres database.

my_blog2_development=# \dg+
                                          List of roles
 Role name |                         Attributes                         | Member of | Description 
-----------+------------------------------------------------------------+-----------+-------------
 datacloud |                                                            | {}        | 
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}        | 
 suzart    | Superuser                                                  | {}        | 

Hope this can bring more context to the possible issue. I'll try harder to see if I can find anything.

Regards

@paulcsmith
Copy link
Member

I cloned it and it ran ok for me. I'm not sure why it didn't run at all with no output.

What OS and Crystal version are you using?

One thing you may want to try is switching lucky_migrator from version: "~> 0.4" to branch: master

The master branch has a couple fixes that may make it work.

If that doesn't work hopefully we can figure out what's different about your setup and gets things working for you :)

@paulosuzart
Copy link
Author

paulosuzart commented Feb 8, 2018

Hi @paulcsmith , just tried your suggestion. Nothing makes it run o.0

Here my crystal runnint at my 4.8.0-59-generic #64-Ubuntu yakkety:

Crystal 0.24.1 (2017-12-22)

LLVM: 4.0.0
Default target: x86_64-unknown-linux-gnu

After upgrading to master branch of migrator, I tried with no success.
I then tried:

  private def setup_migration_tracking_tables
    DB.open(LuckyRecord::Repo.settings.url) do |db|
      db.exec create_table_for_tracking_migrations
    end
  rescue e
    puts e.message
  end

and it prints a blank line at runner.cr . It seems like the DB.open is failing to connect to postgres but no specific exception os raised even though the connection url is correct.

Thank you

@paulosuzart
Copy link
Author

@paulcsmith Just found the thing.

Update my pg_hba.conf with the following entry and now it worked:

host    all             all             127.0.0.1/32            trust

Sorry for the confusion. But as it worked with createdb and dropdb this piece was missing. In summary everthing works just as expected. Continuing my exploration and I think this can be closed.

Regards

@paulcsmith
Copy link
Member

No problem! I'm glad you got it working 👍

@paulcsmith paulcsmith removed the bug label Feb 9, 2018
paulcsmith pushed a commit to luckyframework/lucky_migrator that referenced this issue Apr 18, 2018
…y#388 (#95)

* Added bit more detail to migration failures as in #388

* Fixed formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants