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

[#135] Support adding BinaryType Field #137

Merged
merged 1 commit into from
Jul 22, 2024
Merged

Conversation

shimizukawa
Copy link
Member

@shimizukawa shimizukawa commented Jul 22, 2024

  • Support adding BinaryType field.
  • Support forward migration with varchar to varbyte(size).
  • Support backward migration from varbyte to varchar(size).
  • Added BinaryType field to psycopg2 adapter.
  • Testing with example/dj-sql-explorer.

- Support adding BinaryType field.
- Support forward migration with varchar to varbyte(size).
- Support backward migration from varbyte to varchar(size).
- Added BinaryType field to psycopg2 adapter.
- Testing with example/dj-sql-explorer.
@shimizukawa
Copy link
Member Author

Now migration of example/dj-sql-explorer has been fixed.

forward migration

(venv) @shimizukawa ➜ /workspaces/django-redshift-backend/examples/dj-sql-explorer (135-binaryfield-support) $ python manage.py migrate explorer 0018
Operations to perform:
  Target specific migration: 0018_alter_databaseconnection_host_and_more, from explorer
Running migrations:
  Applying explorer.0018_alter_databaseconnection_host_and_more...ALTER TABLE "explorer_databaseconnection" ADD COLUMN "host_tmp" varbyte(255) DEFAULT %s NOT NULL; (params [<django_redshift_backend.psycopg2adapter.RedshiftBinary object at 0x7d87221efd30>])
UPDATE explorer_databaseconnection SET "host_tmp" = "host"::varbyte WHERE "host" IS NOT NULL; (params [])
ALTER TABLE explorer_databaseconnection DROP COLUMN "host" CASCADE; (params [])
ALTER TABLE explorer_databaseconnection RENAME COLUMN "host_tmp" TO "host"; (params [])
ALTER TABLE "explorer_databaseconnection" ADD COLUMN "password_tmp" varbyte(255) DEFAULT %s NOT NULL; (params [<django_redshift_backend.psycopg2adapter.RedshiftBinary object at 0x7d8721d2c810>])
UPDATE explorer_databaseconnection SET "password_tmp" = "password"::varbyte WHERE "password" IS NOT NULL; (params [])
ALTER TABLE explorer_databaseconnection DROP COLUMN "password" CASCADE; (params [])
ALTER TABLE explorer_databaseconnection RENAME COLUMN "password_tmp" TO "password"; (params [])
ALTER TABLE "explorer_databaseconnection" ADD COLUMN "user_tmp" varbyte(255) DEFAULT %s NOT NULL; (params [<django_redshift_backend.psycopg2adapter.RedshiftBinary object at 0x7d8721d2cc20>])
UPDATE explorer_databaseconnection SET "user_tmp" = "user"::varbyte WHERE "user" IS NOT NULL; (params [])
ALTER TABLE explorer_databaseconnection DROP COLUMN "user" CASCADE; (params [])
ALTER TABLE explorer_databaseconnection RENAME COLUMN "user_tmp" TO "user"; (params [])
 OK

backward migrattion

(venv) @shimizukawa ➜ /workspaces/django-redshift-backend/examples/dj-sql-explorer (135-binaryfield-support) $ python manage.py migrate explorer 0017
Operations to perform:
  Target specific migration: 0017_databaseconnection, from explorer
Running migrations:
  Rendering model states... DONE
  Unapplying explorer.0018_alter_databaseconnection_host_and_more...ALTER TABLE "explorer_databaseconnection" ADD COLUMN "user_tmp" varchar(255) DEFAULT %s NOT NULL; (params [''])
UPDATE explorer_databaseconnection SET "user_tmp" = "user"::varchar WHERE "user" IS NOT NULL; (params [])
ALTER TABLE explorer_databaseconnection DROP COLUMN "user" CASCADE; (params [])
ALTER TABLE explorer_databaseconnection RENAME COLUMN "user_tmp" TO "user"; (params [])
ALTER TABLE "explorer_databaseconnection" ADD COLUMN "password_tmp" varchar(255) DEFAULT %s NOT NULL; (params [''])
UPDATE explorer_databaseconnection SET "password_tmp" = "password"::varchar WHERE "password" IS NOT NULL; (params [])
ALTER TABLE explorer_databaseconnection DROP COLUMN "password" CASCADE; (params [])
ALTER TABLE explorer_databaseconnection RENAME COLUMN "password_tmp" TO "password"; (params [])
ALTER TABLE "explorer_databaseconnection" ADD COLUMN "host_tmp" varchar(255) DEFAULT %s NOT NULL; (params [''])
UPDATE explorer_databaseconnection SET "host_tmp" = "host"::varchar WHERE "host" IS NOT NULL; (params [])
ALTER TABLE explorer_databaseconnection DROP COLUMN "host" CASCADE; (params [])
ALTER TABLE explorer_databaseconnection RENAME COLUMN "host_tmp" TO "host"; (params [])
 OK

@shimizukawa
Copy link
Member Author

dj-sql-explorer works fine.
image

@shimizukawa shimizukawa self-assigned this Jul 22, 2024
@shimizukawa shimizukawa merged commit edba79c into master Jul 22, 2024
26 of 27 checks passed
@shimizukawa shimizukawa linked an issue Jul 22, 2024 that may be closed by this pull request
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.

Support adding BinaryFIeld
1 participant