Apply database schema updates automatically in every deployment

Đang mở
#9,484 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
github-actions, helm, kubernetes, postgresql, scala
Lĩnh vực
ci-cd, database, devops

Hướng nghiên cứu

Start with sql/changelog.xml, sql/updates/, and sql/texera_ddl.sql, then trace how local development, single-node deployment, Kubernetes, and CI initialize the database. The issue identifies the migration-tool choice, Kubernetes execution point, and baseline for databases without history as open decisions. Done means every deployment runs one migration step before services start, and CI detects when applying updates to the last release schema does not match texera_ddl.sql.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Task Summary

The resource unification in #9395 changes tables that every deployment already holds, one step at a time, so each step has to reach an existing database by itself. Today it does not. A schema change is written twice, as a numbered file in sql/updates/ listed in sql/changelog.xml and as an edit to sql/texera_ddl.sql, but only local development applies the numbered files on its own. Single-node and Kubernetes load texera_ddl.sql when the database is first created and never again, so upgrading an existing deployment means applying each new update by hand. CI loads only texera_ddl.sql, so nothing checks that the two copies agree.

Local development already follows a sound rule: a new database starts from texera_ddl.sql and records every update as applied, and an existing database applies the updates it lacks, in order. This task makes that rule the one migration step of every deployment, and checks it in CI.

Before
flowchart TB
  ddl["sql/texera_ddl.sql<br/>the whole schema, edited by hand"]
  upd["sql/updates/23.sql … 52.sql<br/>listed in sql/changelog.xml"]
  ld["Local development<br/>applies pending updates"]
  sn["Single-node<br/>updates by hand"]
  k8s["Kubernetes<br/>updates by hand"]
  ci["CI<br/>never runs an update"]
  ddl -- "new database" --> ld
  ddl -- "new database" --> sn
  ddl -- "new database" --> k8s
  ddl -- "every job" --> ci
  upd --> ld
After
flowchart TB
  ddl["sql/texera_ddl.sql<br/>for a new database"]
  upd["sql/updates/NN.sql<br/>one ordered chain"]
  step["One migration step<br/>runs before the services start"]
  ld["Local development"]
  sn["Single-node"]
  k8s["Kubernetes"]
  ci["CI<br/>also checks: last release's schema<br/>+ new updates = texera_ddl.sql"]
  ddl --> step
  upd --> step
  step --> ld
  step --> sn
  step --> k8s
  step --> ci
Scope
  1. One migration step. Single-node, Kubernetes, local development and CI run the same step before the services start, so an upgrade needs no SQL by hand.
  2. A check in CI. The updates, applied to the schema of the last release, must give the same schema as texera_ddl.sql, so a pull request that changes one without the other fails.
  3. One documented rule. The contributor guide says in one place what to write for a schema change.

This task changes no table. Removing the unused scripts 01 to 22 is #7702.

Discussion Points
  1. The tool. Liquibase already defines the chain in sql/changelog.xml, and local databases already carry its databasechangelog table. Flyway, or the plain psql loop that local development runs today, are the alternatives.
  2. Where the step runs on Kubernetes. A Helm hook job runs once per upgrade. An init container runs at every start of a service, and needs a lock so that two replicas do not migrate at once.
  3. Deployments with no history. A single-node or Kubernetes database has never recorded which updates it holds. The first run needs a baseline, either stated by the deployer or detected from the schema.

Done when an existing single-node or Kubernetes deployment upgrades to a release with a new update without anyone running SQL by hand, and CI fails when an update and texera_ddl.sql disagree.

Related: #4400, #6194.

Task Type
  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other
Ngôn ngữ chính
Scala
Star
333
Fork
202
Merge trung bình
3 ngày 11 giờ
Pull request đã merge (30 ngày)
185

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/texera

Tất cả issue của apache/texera

Issue tương tự

Thêm issue về Scala

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.