luarocks / luarocks-site

LuaRocks website and module host
http://luarocks.org
176 stars 36 forks source link

pgmoon question #21

Closed lordnynex closed 9 years ago

lordnynex commented 9 years ago

Sorry to open an issue for this but I've noticed that the most recent release of lapis seems to break the way you're creating your schema.

Again, I'm sorry to create an issue over here but I use this repo as a sort of guide for lapis development and some of my projects use your lapis exec require("schema").make_schema! design. I'm not sure if the current situation is by design or if it's a bug in lapis.

Given Lapis 1.0.4, what is your opinion on the best way to create the schema like you are here? Does it make sense for lapis to support a new command like migration called schema?

leafo commented 9 years ago

pgmoon doesn't use an nginx module for making queries, so ${{pg POSTGRESQL_URL}} and upstream database no longer need to exist in the nginx.conf. (I removed them from this repo a while ago) I also updated the docs to no longer reference the POSTGRES_URL, as it's deprecated: http://leafo.net/lapis/reference/database.html

Running the schema file does use pgmoon. The lapis exec command should still work. Maybe something else is breaking and causing the confusion?

As an aside, I'm not sure if the schema file is the best approach, or at least it needs to be improved. It's convenient but it has the disadvantage of not having any information about which migrations have already been run. This isn't that big of a deal when working solo, but if you bring a new developer into a project it can be annoying to get their database up to date.

I've started doing something like this in a makefile for saving and restoring the schema, along with including which migrations have been run:

schema.sql::
    pg_dump -s -U postgres moonrocks > schema.sql
    pg_dump -a -t lapis_migrations -U postgres moonrocks >> schema.sql

init_schema::
    createdb -U postgres moonrocks
    cat schema.sql | psql -U postgres moonrocks

And then with that I would recommend putting all schema definitions in migrations.

lordnynex commented 9 years ago

This makes sense. I will adjust my apps accordingly. Thanks for the advice.