chore: add liquibase schema versioning#4401
Conversation
aglinxinyuan
left a comment
There was a problem hiding this comment.
Why is this under file-service folder?
I just wanted to keep it with the docker-compose.yml file. Not sure where else to put it. Would |
Yes. Please put it in the SQL folder as a separate docker-compose.yml file so the user can choose whether to use it. Please also fix the Apache header. |
mengw15
left a comment
There was a problem hiding this comment.
I agree with Xinyuan's comments. Additionally, do not hard code the Postgres username and password, since its configurations in storage.conf, and devs may use different credentials. Also please double-check host.docker.internal's cross-platform support.
|
One question, do we need to use docker compose to do this task? is there other options? |
It is easiest for developers if it is integrated into docker compose so that developers don’t need to locally install Liquibase. |
I noticed that host.docker.internal is supported on all platforms except for Linux with Docker Engine/Standalone. Developers using this installation should run |
I don't think there's any straightforward way to avoid hard coding the postgres username and password. Since developers are already manually running the docker-compose.yml in |
aglinxinyuan
left a comment
There was a problem hiding this comment.
LGTM! Please work with @mengw15 to update the wiki. It's optional for user to use this, but it's required for developers who made DDL changes to add sql link in the xml file.
mengw15
left a comment
There was a problem hiding this comment.
LGTM. Left one minor comment
Which change do you prefer? The jooqGenerate only when there is a schema change, or every time the docker compose file is run? |
You can decide. For our main codebase, we will run jooqGenerate each time we compile. |
Sounds good, I'll look into running jooqGenerate in the docker file. |
|
@mengw15 @aglinxinyuan Feel free to merge it if you think it's ready. |
|
@mengw15 @aglinxinyuan I've added the |
…pts to maintain old convention
mengw15
left a comment
There was a problem hiding this comment.
Left some comments, please also test after resolve these comments.
<!-- Thanks for sending a pull request (PR)! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: [Contributing to Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md) 2. Ensure you have added or run the appropriate tests for your PR 3. If the PR is work in progress, mark it a draft on GitHub. 4. Please write your PR title to summarize what this PR proposes, we are following Conventional Commits style for PR titles as well. 5. Be sure to keep the PR description updated to reflect all changes. --> ### What changes were proposed in this PR? <!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes. Here are some tips for you: 1. If you propose a new API, clarify the use case for a new API. 2. If you fix a bug, you can clarify why it is a bug. 3. If it is a refactoring, clarify what has been changed. 3. It would be helpful to include a before-and-after comparison using screenshots or GIFs. 4. Please consider writing useful notes for better and faster reviews. --> This PR adds Liquibase to automate local database migrations. Running `docker compose up` will now automatically apply any pending SQL migrations under `sql/updates` and run `sbt jooqGenerate`, so developers no longer need to manually run SQL scripts after pulling changes. NB: - The author of the PR with the schema change will need to add a `<changeSet>` element to `changelog.xml` so that Liquibase can detect the new update. - `\c texera_db` is a line that is being used in every sql update file under `sql/updates`. However, this is a psql command and not SQL, so Liquibase will throw an error. Authors should not add this line to their update scripts, since the database is already set to `texera_db` for Liquibase in `docker-compose.yml`. ### Any related issues, documentation, discussions? <!-- Please use this section to link other resources if not mentioned already. 1. If this PR fixes an issue, please include `Fixes apache#1234`, `Resolves apache#1234` or `Closes apache#1234`. If it is only related, simply mention the issue number. 2. If there is design documentation, please add the link. 3. If there is a discussion in the mailing list, please add the link. --> Closes apache#4400 ### How was this PR tested? <!-- If tests were added, say they were added here. Or simply mention that if the PR is tested with existing test cases. Make sure to include/update test cases that check the changes thoroughly including negative and positive cases if possible. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. --> Locally ### Was this PR authored or co-authored using generative AI tooling? <!-- If generative AI tooling has been used in the process of authoring this PR, please include the phrase: 'Generated-by: ' followed by the name of the tool and its version. If no, write 'No'. Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details. --> No --------- Co-authored-by: Chen Li <chenli@gmail.com> Co-authored-by: Xinyuan Lin <xinyual3@uci.edu> Co-authored-by: Meng Wang <125719918+mengw15@users.noreply.github.com> Co-authored-by: Meng Wang <simonmengwang123@gmail.com>
What changes were proposed in this PR?
This PR adds Liquibase to automate local database migrations. Running
docker compose upwill now automatically apply any pending SQL migrations undersql/updatesand runsbt jooqGenerate, so developers no longer need to manually run SQL scripts after pulling changes.NB:
<changeSet>element tochangelog.xmlso that Liquibase can detect the new update.\c texera_dbis a line that is being used in every sql update file undersql/updates. However, this is a psql command and not SQL, so Liquibase will throw an error. Authors should not add this line to their update scripts, since the database is already set totexera_dbfor Liquibase indocker-compose.yml.Any related issues, documentation, discussions?
Closes #4400
How was this PR tested?
Locally
Was this PR authored or co-authored using generative AI tooling?
No