Scifabric / pybossa

PYBOSSA is the ultimate crowdsourcing framework (aka microtasking) to analyze or enrich data that can't be processed by machines alone.
http://pybossa.com
GNU Affero General Public License v3.0
745 stars 269 forks source link

alembic autogenerate droping all tables #1317

Closed Lythimus closed 8 years ago

Lythimus commented 8 years ago

Using the majority of the pybossa default configs, autogenerating a migration file produces a script which will drop all tables. I'd like to be able to autogenerate migrations.

from pybossa.core import db
target_metadata = db.Model.metadata

Here is an example of the output during generation:

INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.ddl.postgresql] Detected sequence named 'task_run_id_seq' as owned by integer column 'task_run(id)', assuming SERIAL and omitting
INFO  [alembic.autogenerate.compare] Detected removed table u'task_run'
INFO  [alembic.autogenerate.compare] Detected removed table u'category'
INFO  [alembic.ddl.postgresql] Detected sequence named 'auditlog_id_seq' as owned by integer column 'auditlog(id)', assuming SERIAL and omitting
INFO  [alembic.autogenerate.compare] Detected removed table u'auditlog'
INFO  [alembic.autogenerate.compare] Detected removed table u'task'
INFO  [alembic.autogenerate.compare] Detected removed table u'user'
INFO  [alembic.ddl.postgresql] Detected sequence named 'blogpost_id_seq' as owned by integer column 'blogpost(id)', assuming SERIAL and omitting
INFO  [alembic.autogenerate.compare] Detected removed table u'blogpost'
INFO  [alembic.autogenerate.compare] Detected removed table u'project'
INFO  [alembic.ddl.postgresql] Detected sequence named 'webhook_id_seq' as owned by integer column 'webhook(id)', assuming SERIAL and omitting
INFO  [alembic.autogenerate.compare] Detected removed table u'webhook'
INFO  [alembic.ddl.postgresql] Detected sequence named 'result_id_seq' as owned by integer column 'result(id)', assuming SERIAL and omitting
INFO  [alembic.autogenerate.compare] Detected removed table u'result'
  Generating /var/www/pybossa/alembic/versions/08d04fab0868_.py ... done
teleyinex commented 8 years ago

We use alembic to do the migrations. Once you have the DB configured, you can downgrade or upgrade the DB with these commands:

alembic upgrade head -> this will do all the migrations to the latest version

alembic downgrade VERSION -> this will do the migration to a give version.

Thus, if you need to upgrade, just run alembic upgrade head and everything should be fine :-)

mcguegi commented 3 years ago

@Lythimus did you find out what was happening? I have the same problem :(

Lythimus commented 3 years ago

@mcguegi We actually haven't had to update the model of Pybossa much, so I haven't even needed to create migrations since I posted this. I can't recall what I did, but I do believe I got it working, though I may have had to alter the migration file a bit after it was created.

WeebNetsu commented 2 years ago

https://stackoverflow.com/a/45700134/15586166 This might help, its possibly a problem with your env (if I understand your question correctly)