-
Notifications
You must be signed in to change notification settings - Fork 9
feat(storage): add PostgreSQL storage-table schema definitions #936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| 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); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.