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

[feature] defined order of properties in API Form #1491

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Pralish
Copy link
Contributor

@Pralish Pralish commented Mar 24, 2023

Addresses:
#555
#1381

Demo:

Screen.Recording.2023-03-23.at.7.01.06.PM.mov

@github-actions
Copy link

Deployed review-app can be viewed at https://review-1491.violet-test.net

@github-actions
Copy link

Deployed review-app can be viewed at https://review-1491.violet-test.net

@Pralish Pralish requested a review from donrestarone March 24, 2023 15:39
@donrestarone donrestarone changed the title [Feat] change the order of properties for API Form [feature] defined order of properties in API Form Mar 24, 2023
@github-actions
Copy link

Deployed review-app can be viewed at https://review-1491.violet-test.net

@@ -97,7 +97,16 @@ class ApiNamespace < ApplicationRecord
else
self.none
end
}
}

Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

@donrestarone donrestarone Mar 25, 2023

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?

Copy link
Contributor Author

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 

Copy link
Contributor

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?

@donrestarone
Copy link
Contributor

@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

@donrestarone
Copy link
Contributor

@Pralish we are pivoting this task to: #1512 --

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

Successfully merging this pull request may close these issues.

2 participants