Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ jobs:
scripts/ci/prepull-images.sh \
mysql:8.0 \
mysql:8.4 \
postgres:16 \
localstack/localstack:3.0 \
testcontainers/ryuk:0.13.0
- name: "Test"
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
github.com/google/uuid v1.6.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0
github.com/hmarr/codeowners v1.2.1
github.com/jackc/pgx/v5 v5.10.0
github.com/pingcap/tidb/pkg/parser v0.0.0-20260504140133-511dba1dbe17
github.com/planetscale/planetscale-go v0.155.0
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
Expand All @@ -35,6 +36,7 @@ require (
github.com/testcontainers/testcontainers-go v0.40.0
github.com/testcontainers/testcontainers-go/modules/localstack v0.40.0
github.com/testcontainers/testcontainers-go/modules/mysql v0.40.0
github.com/testcontainers/testcontainers-go/modules/postgres v0.40.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0
go.opentelemetry.io/otel v1.43.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.43.0
Expand Down Expand Up @@ -161,6 +163,9 @@ require (
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/serf v0.10.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.6 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
Expand Down
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,14 @@ github.com/hmarr/codeowners v1.2.1 h1:+9yndrwG0UVP1GkLBEQMSbSUNeLpbrbL924SRthA/9
github.com/hmarr/codeowners v1.2.1/go.mod h1:KPlR1p/B4owPjwfNIBueWlOP4CmqlQFX9b6nANG6j40=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.10.0 h1:VhSvgU2jSli8o3AqIEOTJr7rZwAEUVo4E4XhR94Zfr0=
github.com/jackc/pgx/v5 v5.10.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
Expand Down Expand Up @@ -397,6 +405,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/linkdata/deadlock v0.5.5 h1:d6O+rzEqasSfamGDA8u7bjtaq7hOX8Ha4Zn36Wxrkvo=
github.com/linkdata/deadlock v0.5.5/go.mod h1:tXb28stzAD3trzEEK0UJWC+rZKuobCoPktPYzebb1u0=
github.com/lmittmann/tint v1.1.3 h1:Hv4EaHWXQr+GTFnOU4VKf8UvAtZgn0VuKT+G0wFlO3I=
Expand All @@ -420,6 +430,8 @@ github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+Ei
github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw=
github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mdelapenya/tlscert v0.2.0 h1:7H81W6Z/4weDvZBNOfQte5GpIMo0lGYEeWbkGp5LJHI=
github.com/mdelapenya/tlscert v0.2.0/go.mod h1:O4njj3ELLnJjGdkN7M/vIVCpZ+Cf0L6muqOG4tLSl8o=
github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g=
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos=
Expand Down Expand Up @@ -625,6 +637,8 @@ github.com/testcontainers/testcontainers-go/modules/localstack v0.40.0 h1:b+lN2C
github.com/testcontainers/testcontainers-go/modules/localstack v0.40.0/go.mod h1:8LuTSboTo2MJKFKV5xH6z4ZH1s3jhRJWwvtPJzKogj4=
github.com/testcontainers/testcontainers-go/modules/mysql v0.40.0 h1:P9Txfy5Jothx2wFdcus0QoSmX/PKSIXZxrTbZPVJswA=
github.com/testcontainers/testcontainers-go/modules/mysql v0.40.0/go.mod h1:oZPHHqJqXG7FD8OB/yWH7gLnDvZUlFHAVJNrGftL+eg=
github.com/testcontainers/testcontainers-go/modules/postgres v0.40.0 h1:s2bIayFXlbDFexo96y+htn7FzuhpXLYJNnIuglNKqOk=
github.com/testcontainers/testcontainers-go/modules/postgres v0.40.0/go.mod h1:h+u/2KoREGTnTl9UwrQ/g+XhasAT8E6dClclAADeXoQ=
github.com/tinylib/msgp v1.6.4 h1:mOwYbyYDLPj35mkA2BjjYejgJk9BuHxDdvRnb6v2ZcQ=
github.com/tinylib/msgp v1.6.4/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA=
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
Expand Down
42 changes: 42 additions & 0 deletions pkg/schema/postgres/applies.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
CREATE TABLE applies (
id bigint GENERATED BY DEFAULT AS IDENTITY,
apply_identifier varchar(255) NOT NULL,
lock_id bigint NOT NULL,
plan_id bigint NOT NULL,
database_name varchar(255) NOT NULL,
database_type varchar(50) NOT NULL,
repository varchar(255) NOT NULL,
pull_request bigint NOT NULL,
environment varchar(50) NOT NULL,
deployment varchar(255) NOT NULL DEFAULT '',
caller varchar(255) NOT NULL DEFAULT '',
installation_id bigint NOT NULL DEFAULT 0,
external_id varchar(255) NOT NULL DEFAULT '',
idempotency_key varchar(255) DEFAULT NULL,
engine varchar(50) NOT NULL,
state varchar(100) NOT NULL,
error_message text,
options jsonb NOT NULL,
attempt integer NOT NULL DEFAULT 0,
lease_owner varchar(255) NOT NULL DEFAULT '',
lease_token varchar(64) NOT NULL DEFAULT '',
lease_acquired_at timestamp DEFAULT NULL,
started_at timestamp DEFAULT NULL,
completed_at timestamp DEFAULT NULL,
revert_skipped_at timestamp DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_applies_apply_identifier ON applies (apply_identifier);
CREATE UNIQUE INDEX idx_applies_idempotency_key ON applies (idempotency_key);
CREATE INDEX idx_applies_lock_id ON applies (lock_id);
CREATE INDEX idx_applies_plan_id ON applies (plan_id);
CREATE INDEX idx_applies_database_env ON applies (database_name, database_type, environment);
CREATE INDEX idx_applies_database_env_deployment ON applies (database_name, database_type, environment, deployment);
CREATE INDEX idx_applies_repo_pr ON applies (repository, pull_request);
CREATE INDEX idx_applies_created_id ON applies (created_at, id);
CREATE INDEX idx_applies_environment_created_id ON applies (environment, created_at, id);
CREATE INDEX idx_applies_state_created_id ON applies (state, created_at, id);
CREATE INDEX idx_applies_environment_state_created_id ON applies (environment, state, created_at, id);
CREATE INDEX idx_applies_completed_at_state ON applies (completed_at, state);
17 changes: 17 additions & 0 deletions pkg/schema/postgres/apply_comments.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE TABLE apply_comments (
id bigint GENERATED BY DEFAULT AS IDENTITY,
apply_id bigint NOT NULL,
comment_state varchar(50) NOT NULL,
github_comment_id bigint NOT NULL,
posted_volume integer DEFAULT NULL,
posted_phase varchar(32) DEFAULT NULL,
pending_freeze_github_comment_id bigint DEFAULT NULL,
edit_count integer NOT NULL DEFAULT 0,
last_edited_at timestamp DEFAULT NULL,
superseded_at timestamp DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_apply_comments_apply_comment_state ON apply_comments (apply_id, comment_state);
CREATE INDEX idx_apply_comments_github_comment ON apply_comments (github_comment_id);
15 changes: 15 additions & 0 deletions pkg/schema/postgres/apply_control_requests.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE TABLE apply_control_requests (
id bigint GENERATED BY DEFAULT AS IDENTITY,
apply_id bigint NOT NULL,
operation varchar(50) NOT NULL,
status varchar(50) NOT NULL,
requested_by varchar(255) NOT NULL DEFAULT '',
error_message text,
metadata jsonb NOT NULL,
completed_at timestamp DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_apply_control_requests_apply_operation ON apply_control_requests (apply_id, operation);
CREATE INDEX idx_apply_control_requests_status ON apply_control_requests (status, created_at);
18 changes: 18 additions & 0 deletions pkg/schema/postgres/apply_logs.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE apply_logs (
id bigint GENERATED BY DEFAULT AS IDENTITY,
apply_id bigint NOT NULL,
task_id bigint DEFAULT NULL,
level varchar(20) NOT NULL DEFAULT 'info',
event_type varchar(100) NOT NULL,
source varchar(100) NOT NULL DEFAULT 'schemabot',
message text NOT NULL,
old_state varchar(100) DEFAULT NULL,
new_state varchar(100) DEFAULT NULL,
metadata jsonb DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE INDEX idx_apply_logs_apply_created ON apply_logs (apply_id, created_at);
CREATE INDEX idx_apply_logs_task_id ON apply_logs (task_id);
CREATE INDEX idx_apply_logs_level ON apply_logs (level);
CREATE INDEX idx_apply_logs_event_type ON apply_logs (event_type);
29 changes: 29 additions & 0 deletions pkg/schema/postgres/apply_operations.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CREATE TABLE apply_operations (
id bigint GENERATED BY DEFAULT AS IDENTITY,
apply_id bigint NOT NULL,
deployment varchar(255) NOT NULL,
operation_key varchar(255) NOT NULL DEFAULT '',
operation_kind varchar(32) NOT NULL DEFAULT 'work',
target varchar(255) NOT NULL DEFAULT '',
external_id varchar(255) DEFAULT NULL,
external_operation_id varchar(255) DEFAULT NULL,
engine_resume_context varchar(255) DEFAULT NULL,
engine_resume_metadata jsonb DEFAULT NULL,
state varchar(100) NOT NULL DEFAULT 'pending',
error_message text,
cutover_policy varchar(16) NOT NULL DEFAULT 'rolling',
on_failure varchar(16) NOT NULL DEFAULT 'halt',
attempt integer NOT NULL DEFAULT 0,
lease_owner varchar(255) NOT NULL DEFAULT '',
lease_token varchar(64) NOT NULL DEFAULT '',
lease_acquired_at timestamp DEFAULT NULL,
started_at timestamp DEFAULT NULL,
completed_at timestamp DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_apply_operations_apply_deployment_key ON apply_operations (apply_id, deployment, operation_key);
CREATE INDEX idx_apply_operations_deployment_state ON apply_operations (deployment, state);
CREATE INDEX idx_apply_operations_state_created_id ON apply_operations (state, created_at, id);
CREATE INDEX idx_apply_operations_apply_created_id ON apply_operations (apply_id, created_at, id);
12 changes: 12 additions & 0 deletions pkg/schema/postgres/apply_target_locks.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CREATE TABLE apply_target_locks (
id bigint GENERATED BY DEFAULT AS IDENTITY,
database_name varchar(255) NOT NULL,
database_type varchar(50) NOT NULL,
environment varchar(50) NOT NULL,
deployment varchar(255) NOT NULL DEFAULT '',
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_apply_target_locks_target ON apply_target_locks (database_name, database_type, environment);
CREATE UNIQUE INDEX idx_apply_target_locks_target_v2 ON apply_target_locks (database_name, database_type, environment, deployment);
25 changes: 25 additions & 0 deletions pkg/schema/postgres/checks.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CREATE TABLE checks (
id bigint GENERATED BY DEFAULT AS IDENTITY,
repository varchar(255) NOT NULL,
pull_request bigint NOT NULL,
head_sha varchar(64) NOT NULL,
environment varchar(50) NOT NULL,
database_type varchar(50) NOT NULL,
database_name varchar(255) NOT NULL,
check_run_id bigint DEFAULT NULL,
apply_id bigint DEFAULT NULL,
has_changes boolean NOT NULL DEFAULT TRUE,
status varchar(255) NOT NULL,
conclusion varchar(255) DEFAULT NULL,
blocking_reason varchar(255) DEFAULT NULL,
error_message text,
change_summary varchar(255) DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_checks_check_key ON checks (repository, pull_request, environment, database_type, database_name);
CREATE INDEX idx_checks_repo_env_db ON checks (repository, environment, database_type, database_name);
CREATE INDEX idx_checks_repo_pr ON checks (repository, pull_request);
CREATE INDEX idx_checks_check_run ON checks (check_run_id);
CREATE INDEX idx_checks_apply_id ON checks (apply_id);
14 changes: 14 additions & 0 deletions pkg/schema/postgres/locks.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE TABLE locks (
id bigint GENERATED BY DEFAULT AS IDENTITY,
database_name varchar(255) NOT NULL,
database_type varchar(50) NOT NULL,
repository varchar(255) NOT NULL,
pull_request bigint NOT NULL,
owner varchar(255) NOT NULL,
pending_plan_id varchar(255) NOT NULL DEFAULT '',
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_locks_database ON locks (database_name, database_type);
CREATE INDEX idx_locks_repo_pr ON locks (repository, pull_request);
17 changes: 17 additions & 0 deletions pkg/schema/postgres/plan_comments.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE TABLE plan_comments (
id bigint GENERATED BY DEFAULT AS IDENTITY,
repository varchar(255) NOT NULL,
pull_request bigint NOT NULL,
database_name varchar(255) NOT NULL,
database_type varchar(50) NOT NULL,
environment_scope varchar(255) NOT NULL DEFAULT '',
head_sha varchar(64) NOT NULL,
github_comment_id bigint NOT NULL,
github_node_id varchar(255) NOT NULL,
minimized_at timestamp DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE INDEX idx_plan_comments_slot ON plan_comments (repository, pull_request, database_name, database_type, minimized_at);
CREATE INDEX idx_plan_comments_github_comment ON plan_comments (github_comment_id);
20 changes: 20 additions & 0 deletions pkg/schema/postgres/plans.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE TABLE plans (
id bigint GENERATED BY DEFAULT AS IDENTITY,
plan_identifier varchar(255) NOT NULL,
database_name varchar(255) NOT NULL,
database_type varchar(50) NOT NULL,
deployment varchar(255) NOT NULL DEFAULT '',
target varchar(255) NOT NULL DEFAULT '',
repository varchar(255) NOT NULL,
pull_request bigint NOT NULL,
schema_path varchar(1024) NOT NULL DEFAULT '',
environment varchar(50) NOT NULL DEFAULT '',
schema_files jsonb NOT NULL,
plan_data jsonb NOT NULL,
head_sha varchar(64) NOT NULL DEFAULT '',
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_plans_plan_identifier ON plans (plan_identifier);
CREATE INDEX idx_plans_repo_pr ON plans (repository, pull_request);
CREATE INDEX idx_plans_database_env ON plans (database_name, database_type, environment);
9 changes: 9 additions & 0 deletions pkg/schema/postgres/settings.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TABLE settings (
id bigint GENERATED BY DEFAULT AS IDENTITY,
setting_key varchar(255) NOT NULL,
setting_value text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_settings_setting_key ON settings (setting_key);
42 changes: 42 additions & 0 deletions pkg/schema/postgres/tasks.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
CREATE TABLE tasks (
id bigint GENERATED BY DEFAULT AS IDENTITY,
task_identifier varchar(255) NOT NULL,
apply_id bigint NOT NULL,
apply_operation_id bigint DEFAULT NULL,
plan_id bigint NOT NULL,
database_name varchar(255) NOT NULL,
database_type varchar(50) NOT NULL,
namespace varchar(255) NOT NULL DEFAULT '',
table_name varchar(255) DEFAULT NULL,
shard varchar(255) NOT NULL DEFAULT '',
ddl text,
ddl_action varchar(50) DEFAULT NULL,
engine varchar(50) NOT NULL,
repository varchar(255) NOT NULL,
pull_request bigint NOT NULL,
environment varchar(50) NOT NULL,
state varchar(100) NOT NULL,
error_message text,
options jsonb DEFAULT NULL,
attempt integer NOT NULL DEFAULT 0,
rows_copied bigint DEFAULT 0,
rows_total bigint DEFAULT 0,
progress_percent integer DEFAULT 0,
eta_seconds integer DEFAULT NULL,
checksum_rows_checked bigint DEFAULT 0,
checksum_rows_total bigint DEFAULT 0,
cutover_attempts integer NOT NULL DEFAULT 0,
is_instant boolean DEFAULT FALSE,
engine_migration_id varchar(255) DEFAULT NULL,
started_at timestamp DEFAULT NULL,
Comment thread
Kiran01bm marked this conversation as resolved.
completed_at timestamp DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_tasks_task_identifier ON tasks (task_identifier);
CREATE INDEX idx_tasks_apply_id ON tasks (apply_id);
CREATE INDEX idx_tasks_apply_operation_id ON tasks (apply_operation_id);
CREATE INDEX idx_tasks_database ON tasks (database_name);
CREATE INDEX idx_tasks_repo_pr ON tasks (repository, pull_request);
CREATE INDEX idx_tasks_state ON tasks (state);
30 changes: 30 additions & 0 deletions pkg/schema/postgres/webhook_events.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE TABLE webhook_events (
id bigint GENERATED BY DEFAULT AS IDENTITY,
provider varchar(50) NOT NULL DEFAULT 'github',
delivery_id varchar(64) NOT NULL,
event varchar(100) NOT NULL,
action varchar(100) NOT NULL DEFAULT '',
repository varchar(255) NOT NULL DEFAULT '',
pull_request bigint NOT NULL DEFAULT 0,
head_sha varchar(64) NOT NULL DEFAULT '',
tenant_id varchar(255) NOT NULL DEFAULT '',
payload jsonb NOT NULL,
state varchar(50) NOT NULL,
attempts bigint NOT NULL DEFAULT 0,
lease_owner varchar(255) DEFAULT NULL,
lease_token varchar(64) DEFAULT NULL,
lease_expires_at timestamp DEFAULT NULL,
retry_after timestamp DEFAULT NULL,
last_error text,
received_at timestamp NOT NULL,
started_at timestamp DEFAULT NULL,
completed_at timestamp DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_webhook_events_provider_delivery ON webhook_events (provider, delivery_id);
CREATE INDEX idx_webhook_events_claimable ON webhook_events (state, retry_after, lease_expires_at, created_at);
CREATE INDEX idx_webhook_events_provider_repo_pr ON webhook_events (provider, repository, pull_request);
CREATE INDEX idx_webhook_events_head_sha ON webhook_events (head_sha);
CREATE INDEX idx_webhook_events_received_at ON webhook_events (received_at);
Loading
Loading