-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat: manage the sql migration and schema changes in the main repository #685
Comments
We will manage the database migration following the flowchart below: Explanation:
How we do upgrade and downgrade? Suppose we have 2 version migration files:
upgrade: we will apply the downgrade: we will apply the About the up and down file
CREATE TABLE IF NOT EXISTS users(
user_id serial PRIMARY KEY,
username VARCHAR (50) UNIQUE NOT NULL,
password VARCHAR (50) NOT NULL,
email VARCHAR (300) UNIQUE NOT NULL
);
DROP TABLE IF EXISTS users; |
How do we run mutiple up files? flowchart TD
version-1 -- up/down files --> version-2
version-2 -- up/down files --> version-3
version-1 -- Some users want to upgrade Bucketeer from 1 to 3 --> version-3
|
@kentakozuka The migrate lib that we use has 2 functions can apply those up/down files.
|
@Ubisoft-potato Thanks for the replay! What is the real-world steps when users upgrade Bucketeer?
|
@kentakozuka Yes, the first step is right which is used to update the latest batch service. Here is one thing that I want to point out: the up/down file represents the changes that we added to the database, not all of the table schemas. For example:
CREATE TABLE IF NOT EXISTS users(
user_id serial PRIMARY KEY,
password VARCHAR (50) NOT NULL,
email VARCHAR (300) UNIQUE NOT NULL
);
ALTER TABLE users
ADD COLUMN name VARCHAR(100); So in this case, when we upgrade from Maybe we will add or change some new columns in the third file upwards. Anyway, we just need to apply those up files. The "down" file corresponds to the SQL revert of the "up" file. If we add some column in up file, then the down file will remove those column. |
Is the following scenario may happen? If the new version contains |
Yes, it could be happened. We should ensure that the database is up to date before upgrading the service, in general. |
It would be great that we could avoid this kind of errors in some way.(if possible 😄 ) |
Do you know how the Mattermost handles this case? |
Mattermost make their migration as a CLI tool for user, so user can do the migration before they update Mattermost. You can find it here: https://docs.mattermost.com/manage/command-line-tools.html#mattermost-db |
I found that Helm Charts can define charts dependency relation, maybe we can make batch service as the first service to be installed. |
That would be nice! One thing to keep in mind is that it is hard to cover all possible scenarios. Also, because the Note that the |
CLI solution looks nice! |
@kentakozuka Sorry! I forgot to update this issue. After conducting further research on Helm, I have discovered a better method for performing migration after installing or upgrading Bucketeer Helm Charts. We can use Helm Hooks to do migration after we install or upgrade batch service successfully. There is a blog that show use case of Helm Hooks. |
@Ubisoft-potato Helm hooks sounds good 😄 |
Currently, we manage the SQL migration and schema changes in another repository. This must be done in the main repository. Otherwise, people hosting the project can't get the updates.
In addition to that, we will modify the migration-mysql service implementation not to access the GitHub repo so that we don't have to put an extra secret (GitHub personal access token) on the Kubernetes cluster.
The text was updated successfully, but these errors were encountered: