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 sometimes end with status 1 #488

Open
itsdkey opened this issue Oct 12, 2022 · 4 comments
Open

Migrations sometimes end with status 1 #488

itsdkey opened this issue Oct 12, 2022 · 4 comments
Labels

Comments

@itsdkey
Copy link

itsdkey commented Oct 12, 2022

Hi there,

I started to run into a weird issue in my GitHub actions. Sometimes my migrations just don't want to apply on my Postgres DB:

The output of the step running on GitHub actions:

INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 616e0cbe0c24 -> 7001b6cb06f8, empty message.
1

The step does nothing difficult:

docker-compose run --rm app sh -c "wait-for-it.sh db:5432 -- flask db upgrade -d /app/migrations heads"

The migration itself is also easy:

def upgrade():
    with op.get_context().autocommit_block():
        op.execute(
            """
            ALTER TYPE aggregationperiodtype ADD VALUE IF NOT EXISTS 'WEEKLY';
            """
        )

This happens randomly (not always on this migration, sometimes on different and sometimes it passed without an error).
Is it also possible to get more detail on this kind of error?

requirements:
Werkzeug==2.2.2
Flask==2.0.3
Flask-Migrate==3.1.0
Flask-SQLAlchemy==2.5.1
SQLAlchemy==1.4.31

@miguelgrinberg
Copy link
Owner

I don't understand what you are saying that happens that is wrong. Is it just the 1 exit code? Or are there migrations that are not being applied as well? The exit code comes from Alembic, not from this package, so I'm not sure which conditions trigger an exit code 1.

@itsdkey
Copy link
Author

itsdkey commented Oct 12, 2022

Sorry for not pointing this out. Yes, the exit code 1 is what bothers me. Okay then I'll try to find the answer there :)

@miguelgrinberg
Copy link
Owner

Actually, I wonder if you have a bad logging configuration, which prevents Alembic from printing error messages. This used to be an issue a while ago. If you created your migration repository using an older Flask-Migrate release, your configuration may have this problem. Compare the alembic.ini file in your migrations folder against the most up-to-date template to make sure.

@abmusse
Copy link

abmusse commented Dec 14, 2023

I ran into a similar issue as the OP. I have an older Flask-Migrate and now upgraded to the latest version. After updating to the latest ini file from the template linked above I was able see the error message being returned. I then resolved the issue and now flask db upgrade works as expected.

Thanks for posting this solution @miguelgrinberg

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

No branches or pull requests

3 participants