This is an automated email from the ASF dual-hosted git repository.
mengw15 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git
The following commit(s) were added to refs/heads/main by this push:
new fa376d0c18 chore: add liquibase schema versioning (#4401)
fa376d0c18 is described below
commit fa376d0c1818d3c2e1c7b589e4d0f877ad51cb1e
Author: Grace Chia <[email protected]>
AuthorDate: Fri May 1 19:42:29 2026 -0700
chore: add liquibase schema versioning (#4401)
<!--
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 #1234`, `Resolves
#1234`
or `Closes #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 #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 <[email protected]>
Co-authored-by: Xinyuan Lin <[email protected]>
Co-authored-by: Meng Wang <[email protected]>
Co-authored-by: Meng Wang <[email protected]>
---
sql/changelog.xml | 33 +++++++++++++++++++++++++++++++++
sql/docker-compose.yml | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+)
diff --git a/sql/changelog.xml b/sql/changelog.xml
new file mode 100644
index 0000000000..7e6bd1606a
--- /dev/null
+++ b/sql/changelog.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+-->
+
+<databaseChangeLog
+ xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
+ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.9.xsd">
+
+ <!-- example changeSet
+ <changeSet id="1" author="author">
+ <sqlFile path="sql/updates/1.sql"/>
+ </changeSet>
+ -->
+
+</databaseChangeLog>
\ No newline at end of file
diff --git a/sql/docker-compose.yml b/sql/docker-compose.yml
new file mode 100644
index 0000000000..5c6e606135
--- /dev/null
+++ b/sql/docker-compose.yml
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: texera-liquibase
+services:
+ liquibase:
+ image: liquibase/liquibase:4.29
+ volumes:
+ - .:/liquibase/sql
+ - ./changelog.xml:/liquibase/changelog.xml
+ entrypoint: ["/bin/sh", "-c"]
+ command:
+ - |
+ mkdir -p /tmp/sql/updates
+ for f in /liquibase/sql/updates/*.sql
+ do
+ sed 's/^\\c.*//g;/^SET search_path/d' "$$f" >
/tmp/sql/updates/$(basename "$$f")
+ done
+ cp /liquibase/changelog.xml /tmp/changelog.xml
+ liquibase --url=jdbc:postgresql://host.docker.internal:5432/texera_db
--username=postgres --password=postgres --changeLogFile=changelog.xml
--search-path=/tmp update
+ # NOTE: The usernames/passwords above must match your postgres settings
in storage.conf. Update them here if you changed them.
+ # Format: --username=<your-username> --password=<your-password>
+ codegen:
+ image: sbtscala/scala-sbt:eclipse-temurin-17.0.15_6_1.12.9_2.13.18
+ depends_on:
+ liquibase:
+ condition: service_completed_successfully
+ working_dir: /texera
+ volumes:
+ - ../:/texera
+ - ${HOME}/.ivy2:/root/.ivy2
+ - ${HOME}/.sbt:/root/.sbt
+ environment:
+ STORAGE_JDBC_URL:
"jdbc:postgresql://host.docker.internal:5432/texera_db?currentSchema=texera_db,public"
+ command: sbt jooqGenerate
\ No newline at end of file