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 a GitHub workflow to comment the SQL generated by a migration in PRs #303

Merged
merged 7 commits into from
Aug 11, 2024

Conversation

jonathan-d-zhang
Copy link
Contributor

No description provided.

@jonathan-d-zhang jonathan-d-zhang requested review from a team as code owners July 30, 2024 23:50
@jonathan-d-zhang jonathan-d-zhang force-pushed the migration-comment branch 21 times, most recently from fcb0e4e to 74b877f Compare July 31, 2024 02:15
@vipyrsec vipyrsec deleted a comment from github-actions bot Jul 31, 2024
@jonathan-d-zhang jonathan-d-zhang force-pushed the migration-comment branch 2 times, most recently from d1d0f9d to b6a641a Compare July 31, 2024 02:22
@vipyrsec vipyrsec deleted a comment from github-actions bot Jul 31, 2024
Copy link

alembic upgrade --sql ...

INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Generating static SQL
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 6991bcb18f89 -> d80b98a7f9d2, test revision
BEGIN;

-- Running upgrade 6991bcb18f89 -> d80b98a7f9d2

DROP TABLE scans;

UPDATE alembic_version SET version_num='d80b98a7f9d2' WHERE alembic_version.version_num = '6991bcb18f89';

COMMIT;

Copy link

alembic upgrade --sql $prev_head:head

INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Generating static SQL
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 6991bcb18f89 -> b34ca8f2c587, test-revision
BEGIN;

-- Running upgrade 6991bcb18f89 -> b34ca8f2c587

DROP TABLE scans;

UPDATE alembic_version SET version_num='b34ca8f2c587' WHERE alembic_version.version_num = '6991bcb18f89';

COMMIT;

alembic downgrade --sql head:$prev_head

INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Generating static SQL
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b34ca8f2c587 -> 6991bcb18f89, test-revision
BEGIN;

-- Running downgrade b34ca8f2c587 -> 6991bcb18f89

UPDATE alembic_version SET version_num='6991bcb18f89' WHERE alembic_version.version_num = 'b34ca8f2c587';

COMMIT;

@sid-maddy sid-maddy changed the title Add github action to comment the SQL generated by a migration Add a GitHub workflow to comment the SQL generated by a migration in PRs Aug 3, 2024
Co-authored-by: Siddhesh Mhadnak <[email protected]>
Signed-off-by: jonathan-d-zhang <[email protected]>
Copy link

github-actions bot commented Aug 3, 2024

alembic upgrade --sql $prev_head:head

INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Generating static SQL
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 6991bcb18f89 -> 2f5a9d8f24d8, test-revision
BEGIN;

-- Running upgrade 6991bcb18f89 -> 2f5a9d8f24d8

UPDATE alembic_version SET version_num='2f5a9d8f24d8' WHERE alembic_version.version_num = '6991bcb18f89';

COMMIT;

alembic downgrade --sql head:$prev_head

INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Generating static SQL
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade 2f5a9d8f24d8 -> 6991bcb18f89, test-revision
BEGIN;

-- Running downgrade 2f5a9d8f24d8 -> 6991bcb18f89

UPDATE alembic_version SET version_num='6991bcb18f89' WHERE alembic_version.version_num = '2f5a9d8f24d8';

COMMIT;

sid-maddy and others added 2 commits August 11, 2024 21:11
This avoids having to reimplement Alembic's revision graph logic.

Signed-off-by: Siddhesh Mhadnak <[email protected]>
ci(migration-sql): checkout base commit to figure out the base revision
@sid-maddy sid-maddy merged commit 5d2d481 into main Aug 11, 2024
7 checks passed
@sid-maddy sid-maddy deleted the migration-comment branch August 11, 2024 15:54
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.

2 participants