-
Notifications
You must be signed in to change notification settings - Fork 14
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
Initial configuration for Flyway #178
Merged
rishabhpoddar
merged 15 commits into
supertokens:feat/auto-migration-flyway
from
antsab20:flyway-migration
Jan 3, 2024
Merged
Initial configuration for Flyway #178
rishabhpoddar
merged 15 commits into
supertokens:feat/auto-migration-flyway
from
antsab20:flyway-migration
Jan 3, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rishabhpoddar
suggested changes
Dec 27, 2023
antsab20
commented
Dec 28, 2023
src/main/java/io/supertokens/storage/postgresql/ConnectionPool.java
Outdated
Show resolved
Hide resolved
rishabhpoddar
suggested changes
Dec 28, 2023
src/main/java/io/supertokens/storage/postgresql/FlywayMigration.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/FlywayMigration.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/FlywayMigration.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Outdated
Show resolved
Hide resolved
src/test/java/io/supertokens/storage/postgresql/test/FlywayMigrationTest.java
Show resolved
Hide resolved
antsab20
commented
Dec 28, 2023
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Outdated
Show resolved
Hide resolved
rishabhpoddar
suggested changes
Dec 29, 2023
src/main/java/io/supertokens/storage/postgresql/FlywayMigration.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/FlywayMigration.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Show resolved
Hide resolved
rishabhpoddar
suggested changes
Dec 29, 2023
rishabhpoddar
suggested changes
Dec 29, 2023
...ources/db/migration/access_token_signing_key_dynamic_false/V1__3.0.0._access_token_false.sql
Outdated
Show resolved
Hide resolved
...esources/db/migration/access_token_signing_key_dynamic_true/V2__3.0.0._access_token_true.sql
Outdated
Show resolved
Hide resolved
rishabhpoddar
suggested changes
Jan 1, 2024
src/main/java/io/supertokens/storage/postgresql/ConnectionPool.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/migrations/V4__plugin_version_5_0_4.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/migrations/V1__plugin_version_3_0_0.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Show resolved
Hide resolved
src/test/java/io/supertokens/storage/postgresql/test/FlywayMigrationTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/supertokens/storage/postgresql/test/FlywayMigrationTest.java
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/FlywayMigration.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/config/PostgreSQLConfig.java
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Show resolved
Hide resolved
rishabhpoddar
suggested changes
Jan 2, 2024
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Outdated
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/migrations/V1__init_database.java
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/queries/BaselineMigrationQueries.java
Outdated
Show resolved
Hide resolved
rishabhpoddar
suggested changes
Jan 3, 2024
src/main/java/io/supertokens/storage/postgresql/queries/GeneralQueries.java
Show resolved
Hide resolved
src/main/java/io/supertokens/storage/postgresql/queries/GeneralQueries.java
Show resolved
Hide resolved
src/test/java/io/supertokens/storage/postgresql/test/FlywayMigrationTest.java
Show resolved
Hide resolved
rishabhpoddar
changed the base branch from
master
to
feat/auto-migration-flyway
January 3, 2024 16:11
rishabhpoddar
merged commit Jan 3, 2024
cdcf294
into
supertokens:feat/auto-migration-flyway
0 of 2 checks passed
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of change
Currently users have to manually run SQL scripts for migration.
A solution would be to use Flyway for automatic database migration at Runtime. This will make it easier to migrate and track migration changes.
Technical solution
Flyway migrations will be included in the postgresql-plugin:
Directory structure:
|- /db/
|- /migration/
|- /access_token_signing_key_dynamic_false
|- /access_token_signing_key_dynamic_true
|- /common
The reason why we have 3 directory for migration is because some migrations are conditionally applied or skipped. Therefore, when I am building the location where Flyway searches for migration scripts, I can add or remove them from location. Flyway also offers other solutions to solve such situations. One of them would be custom placeholders, but more documentation will be required to understand if placeholders are a feasible solution for this case.
The default naming convention for migration scripts is as follows: V{version}__{description}.sql . The {version} is used to order the scripts, while the description is there to give some context on the migration. Java migrations are also accepted.
Packaging:
The new directory structure will also have to be present inside the postgresql-plugin.jar. By default it was not. So I had to update the build.gradle jar task.
Implementation details:
When will it be run?
How to run migration for users that have manually run migration?
Will this feature work by default?
What is the expected downtime during migration?
Will there be any code changes required in Core?
Related issues
Test Plan
In order to test this, you will have to run ./gradlew flywayMigrate
Documentation changes
Checklist for important updates
Remaining TODOs for this PR