-
Notifications
You must be signed in to change notification settings - Fork 43
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
[feature] defined order of properties in API Form #1491
base: master
Are you sure you want to change the base?
Conversation
Deployed review-app can be viewed at https://review-1491.violet-test.net |
Deployed review-app can be viewed at https://review-1491.violet-test.net |
Deployed review-app can be viewed at https://review-1491.violet-test.net |
@@ -97,7 +97,16 @@ class ApiNamespace < ApplicationRecord | |||
else | |||
self.none | |||
end | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pralish is this change necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@donrestarone , it's not necessary. The indentation was one space ahead, so fixed it.
def up | ||
remove_index :api_namespaces, name: "index_api_namespaces_on_properties" | ||
|
||
change_column :api_namespaces, :properties, :json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pralish I'm worried this is going to lock up the table for a long time in big apps, causing requests to hang while the DB changes in the background
Can you add strong_migrations
https://github.com/ankane/strong_migrations and see what it says?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@donrestarone, The change is on api_namespaces table. I don't think we have a lot of api_namespaces (less than 50 per app in my opinion).
Having said that, I used the strong_migrations gem and this was the response:
== 20230323050938 ChangePropertiesInApiNamespacesFromJsonbToJson: migrating ===
-- remove_index(:api_namespaces, {:name=>"index_api_namespaces_on_properties"})
-> 0.0019s
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
=== Dangerous operation detected #strong_migrations ===
Changing the type of an existing column blocks reads and writes
while the entire table is rewritten. A safer approach is to:
1. Create a new column
2. Write to both columns
3. Backfill data from the old column to the new column
4. Move reads from the old column to the new column
5. Stop writing to the old column
6. Drop the old column
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pralish yeah that was my fear. Can we add strong migrations to the code base, ensure it runs in CI and then tackle this issue with their suggestion?
@Pralish we are pivoting this task into supporting multiple form representations. This way we don't need to do 5 deployments and we get to keep the JSONB structure for entity representation |
Addresses:
#555
#1381
Demo:
Screen.Recording.2023-03-23.at.7.01.06.PM.mov