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

Add pragma statements automatically if sqlite #9169

Merged
merged 2 commits into from
Apr 10, 2023

Conversation

jakekaplan
Copy link
Contributor

@jakekaplan jakekaplan commented Apr 10, 2023

closes: #8060

Automatically adds PRAGMA statements for sqlite migrations to the migration template. This is referenced in the docs to include for sqlite migrations. This removes the manual step so they're added automatically if connected to a sqlite db.

Example:

prefect server database revision -m test
# sqlite migration
...
def upgrade():
    op.execute("PRAGMA foreign_keys=OFF")
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###
    op.execute("PRAGMA foreign_keys=ON")

def downgrade():
    op.execute("PRAGMA foreign_keys=OFF")
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###
    op.execute("PRAGMA foreign_keys=ON")
# postgres migration
...
def upgrade():
    
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###
    

def downgrade():
    
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###

@jakekaplan jakekaplan requested a review from a team as a code owner April 10, 2023 17:06
@netlify
Copy link

netlify bot commented Apr 10, 2023

Deploy Preview for prefect-docs-preview ready!

Name Link
🔨 Latest commit cb883bc
🔍 Latest deploy log https://app.netlify.com/sites/prefect-docs-preview/deploys/6434421bc0a06e0008af9af3
😎 Deploy Preview https://deploy-preview-9169--prefect-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@jakekaplan jakekaplan merged commit 8d5a6ba into main Apr 10, 2023
asmundo pushed a commit to asmundo/prefect that referenced this pull request May 11, 2023
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

Successfully merging this pull request may close these issues.

Guard against foreign key issues in SQLite migrations
3 participants