Skip to content

chore: add liquibase schema versioning#4401

Merged
mengw15 merged 35 commits into
apache:mainfrom
gracecluvohio:add-liquidbase
May 2, 2026
Merged

chore: add liquibase schema versioning#4401
mengw15 merged 35 commits into
apache:mainfrom
gracecluvohio:add-liquidbase

Conversation

@gracecluvohio
Copy link
Copy Markdown
Contributor

@gracecluvohio gracecluvohio commented Apr 17, 2026

What changes were proposed in this PR?

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?

Closes #4400

How was this PR tested?

Locally

Was this PR authored or co-authored using generative AI tooling?

No

Copy link
Copy Markdown
Contributor

@aglinxinyuan aglinxinyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this under file-service folder?

@gracecluvohio
Copy link
Copy Markdown
Contributor Author

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 sql be a better folder?

@aglinxinyuan
Copy link
Copy Markdown
Contributor

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 sql be a better folder?

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.

Copy link
Copy Markdown
Contributor

@mengw15 mengw15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mengw15
Copy link
Copy Markdown
Contributor

mengw15 commented Apr 17, 2026

One question, do we need to use docker compose to do this task? is there other options?

@gracecluvohio
Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot removed the service label Apr 18, 2026
@aglinxinyuan aglinxinyuan added the ddl-change Changes to the TexeraDB DDL label Apr 18, 2026
@aglinxinyuan aglinxinyuan changed the title ci: add liquibase schema versioning chore: add liquibase schema versioning Apr 18, 2026
@gracecluvohio
Copy link
Copy Markdown
Contributor Author

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.

I noticed that host.docker.internal is supported on all platforms except for Linux with Docker Engine/Standalone. Developers using this installation should run docker run --add-host=host.docker.internal:host-gateway liquibase/liquibase:4.29 instead.

@gracecluvohio
Copy link
Copy Markdown
Contributor Author

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.

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 \sql, I think we can leave it up to the developers to replace it with their postgres username and password.

@github-actions github-actions Bot removed the ddl-change Changes to the TexeraDB DDL label Apr 18, 2026
Copy link
Copy Markdown
Contributor

@aglinxinyuan aglinxinyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

@mengw15 mengw15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left one minor comment

Comment thread sql/docker-compose.yml Outdated
@gracecluvohio
Copy link
Copy Markdown
Contributor Author

It'd be nice to avoid confusion. The ultimate goal of this PR is for developers to not have to manually notify everyone that there was a DDL change. Developers can just run the docker compose file. But when they run the docker compose file without running sbt jooqGenerate, there will be compilation errors, which may lead to confusion.

I'm ok with this change.

Which change do you prefer? The jooqGenerate only when there is a schema change, or every time the docker compose file is run?

@aglinxinyuan
Copy link
Copy Markdown
Contributor

It'd be nice to avoid confusion. The ultimate goal of this PR is for developers to not have to manually notify everyone that there was a DDL change. Developers can just run the docker compose file. But when they run the docker compose file without running sbt jooqGenerate, there will be compilation errors, which may lead to confusion.

I'm ok with this change.

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.

@gracecluvohio
Copy link
Copy Markdown
Contributor Author

It'd be nice to avoid confusion. The ultimate goal of this PR is for developers to not have to manually notify everyone that there was a DDL change. Developers can just run the docker compose file. But when they run the docker compose file without running sbt jooqGenerate, there will be compilation errors, which may lead to confusion.

I'm ok with this change.

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.

@chenlica
Copy link
Copy Markdown
Contributor

@mengw15 @aglinxinyuan Feel free to merge it if you think it's ready.

@gracecluvohio
Copy link
Copy Markdown
Contributor Author

@mengw15 @aglinxinyuan I've added the sbt jooqGenerate service to sql/docker-compose.yml, please take a look.

Copy link
Copy Markdown
Contributor

@mengw15 mengw15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, please also test after resolve these comments.

Comment thread sql/docker-compose.yml Outdated
Comment thread sql/docker-compose.yml Outdated
Comment thread sql/docker-compose.yml Outdated
Comment thread sql/docker-compose.yml Outdated
Copy link
Copy Markdown
Contributor

@aglinxinyuan aglinxinyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mengw15 mengw15 enabled auto-merge (squash) May 2, 2026 02:39
@mengw15 mengw15 merged commit fa376d0 into apache:main May 2, 2026
15 checks passed
SarahAsad23 pushed a commit to SarahAsad23/texera that referenced this pull request May 4, 2026
<!--
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>
zyratlo added a commit to zyratlo/texera that referenced this pull request May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Liquibase Schema Change Automation

6 participants