feat(errors): migrate error-reporting stack from PostgreSQL to MariaDB (BIT-255)
Replace Postgres with MariaDB 11 in docker-compose; convert all database/error_reporting and db/migrations SQL to InnoDB-friendly syntax (DATETIME(6), AUTO_INCREMENT, ON DUPLICATE KEY). Run admin portal DDL in the same migrate one-shot as error_reporting. Switch ingest-api, collector-worker, and api from pg to mysql2 (pools, parameterized queries, transactions). Align ingest writes with er_incident_occurrences and include project_id on idempotency inserts. Add scripts/run-mysql-migrations.sh for host-side applies; update LXC run-migrate/verify, deployment docs, and .env.example (mysql://, ER_MYSQL_*). Verified: npm run build + npm test in ingest-api and collector-worker; npm run build in api. Full docker compose not run here (no local daemon). Co-Authored-By: Paperclip <[email protected]>
This commit is contained in:
1 parent
b0b733d5e1
commit
4604606033
44 files changed
+1547
-993
No files matched your search
@@ -3,7 +3,7 @@
|
||||
This folder contains the relational data model for the Error Reporting platform epic (`BIT-154`), implemented for task `BIT-178`.
|
||||
|
||||
Status and dependency:
|
||||
- Stack baseline is defined by `docs/architecture/ADR-002-error-reporting-platform-phase1.md` (Fastify + PostgreSQL + Redis queue for phase 1).
|
||||
- Runtime target is **MariaDB 10.11+** (or MySQL 8+) with **InnoDB**; Compose and LXC apply the same SQL.
|
||||
- Schema changes must continue through versioned SQL migrations only (`up` + `down`), never ad hoc DDL.
|
||||
|
||||
## Migration layout
|
||||
@@ -15,13 +15,22 @@ Migrations are versioned and reversible (`up` + `down`), timestamped, and idempo
|
||||
3. `20260322044500_add_ingest_idempotency.*`
|
||||
4. `20260322045000_create_collectors_retention_and_audit.*`
|
||||
|
||||
Admin portal tables (`admin_users`, refresh tokens, audit) live under `db/migrations/` at repo root and are applied in the same database by `scripts/docker-migrate.sh` / `deploy/lxc/run-migrate.sh`.
|
||||
|
||||
## Apply manually (example)
|
||||
|
||||
From the repository root, with `mariadb` client and a `mysql://` (or discrete `ER_MYSQL_*`) connection:
|
||||
|
||||
```bash
|
||||
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -f database/error_reporting/migrations/20260322043000_create_error_reporting_core.up.sql
|
||||
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -f database/error_reporting/migrations/20260322044000_create_error_occurrences_and_states.up.sql
|
||||
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -f database/error_reporting/migrations/20260322044500_add_ingest_idempotency.up.sql
|
||||
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -f database/error_reporting/migrations/20260322045000_create_collectors_retention_and_audit.up.sql
|
||||
./scripts/run-mysql-migrations.sh
|
||||
```
|
||||
|
||||
Or run individual files:
|
||||
|
||||
```bash
|
||||
mariadb -h 127.0.0.1 -u er_app -p"$ER_MYSQL_PASSWORD" error_reporting \
|
||||
< database/error_reporting/migrations/20260322043000_create_error_reporting_core.up.sql
|
||||
# ... remaining migrations + db/migrations/*.sql + seed as in scripts/docker-migrate.sh
|
||||
```
|
||||
|
||||
Rollback in reverse order with the matching `*.down.sql` files.
|
||||
|
||||
-5
@@ -1,12 +1,7 @@
|
||||
BEGIN;
|
||||
|
||||
DROP INDEX IF EXISTS er_incidents_project_severity_seen_idx;
|
||||
DROP INDEX IF EXISTS er_incidents_project_state_seen_idx;
|
||||
DROP TABLE IF EXISTS er_incidents;
|
||||
|
||||
DROP INDEX IF EXISTS er_ingest_keys_project_status_idx;
|
||||
DROP TABLE IF EXISTS er_ingest_keys;
|
||||
|
||||
DROP TABLE IF EXISTS er_projects;
|
||||
|
||||
COMMIT;
|
||||
+14
-14
@@ -1,29 +1,29 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS er_projects (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
slug VARCHAR(64) NOT NULL,
|
||||
name VARCHAR(160) NOT NULL,
|
||||
description TEXT NULL,
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
timezone_name VARCHAR(64) NOT NULL DEFAULT 'UTC',
|
||||
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
updated_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||
CONSTRAINT er_projects_slug_uniq UNIQUE (slug),
|
||||
CONSTRAINT er_projects_slug_not_blank_chk CHECK (slug <> '')
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS er_ingest_keys (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
project_id BIGINT NOT NULL,
|
||||
label VARCHAR(128) NOT NULL,
|
||||
token_prefix CHAR(8) NOT NULL,
|
||||
token_hash CHAR(64) NOT NULL,
|
||||
status VARCHAR(16) NOT NULL DEFAULT 'active',
|
||||
last_used_at TIMESTAMP WITHOUT TIME ZONE NULL,
|
||||
expires_at TIMESTAMP WITHOUT TIME ZONE NULL,
|
||||
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
revoked_at TIMESTAMP WITHOUT TIME ZONE NULL,
|
||||
last_used_at DATETIME(6) NULL,
|
||||
expires_at DATETIME(6) NULL,
|
||||
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
revoked_at DATETIME(6) NULL,
|
||||
CONSTRAINT er_ingest_keys_project_fk FOREIGN KEY (project_id)
|
||||
REFERENCES er_projects (id)
|
||||
ON UPDATE CASCADE
|
||||
@@ -38,20 +38,20 @@ CREATE INDEX IF NOT EXISTS er_ingest_keys_project_status_idx
|
||||
ON er_ingest_keys (project_id, status);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS er_incidents (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
project_id BIGINT NOT NULL,
|
||||
fingerprint VARCHAR(128) NOT NULL,
|
||||
title VARCHAR(300) NOT NULL,
|
||||
severity VARCHAR(16) NOT NULL,
|
||||
current_state VARCHAR(16) NOT NULL DEFAULT 'open',
|
||||
first_seen_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
|
||||
last_seen_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
|
||||
first_seen_at DATETIME(6) NOT NULL,
|
||||
last_seen_at DATETIME(6) NOT NULL,
|
||||
occurrences_count BIGINT NOT NULL DEFAULT 1,
|
||||
regression_count INTEGER NOT NULL DEFAULT 0,
|
||||
regression_count INT NOT NULL DEFAULT 0,
|
||||
last_ingest_key_id BIGINT NULL,
|
||||
metadata_json TEXT NULL,
|
||||
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
updated_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||
CONSTRAINT er_incidents_project_fk FOREIGN KEY (project_id)
|
||||
REFERENCES er_projects (id)
|
||||
ON UPDATE CASCADE
|
||||
|
||||
-11
@@ -1,18 +1,7 @@
|
||||
BEGIN;
|
||||
|
||||
DROP INDEX IF EXISTS er_incident_attachments_project_kind_time_idx;
|
||||
DROP INDEX IF EXISTS er_incident_attachments_occurrence_idx;
|
||||
DROP INDEX IF EXISTS er_incident_attachments_incident_time_idx;
|
||||
DROP TABLE IF EXISTS er_incident_attachments;
|
||||
|
||||
DROP INDEX IF EXISTS er_incident_state_history_project_state_time_idx;
|
||||
DROP INDEX IF EXISTS er_incident_state_history_incident_time_idx;
|
||||
DROP TABLE IF EXISTS er_incident_state_history;
|
||||
|
||||
DROP INDEX IF EXISTS er_incident_occurrences_request_id_idx;
|
||||
DROP INDEX IF EXISTS er_incident_occurrences_project_env_time_idx;
|
||||
DROP INDEX IF EXISTS er_incident_occurrences_project_time_idx;
|
||||
DROP INDEX IF EXISTS er_incident_occurrences_incident_time_idx;
|
||||
DROP TABLE IF EXISTS er_incident_occurrences;
|
||||
|
||||
COMMIT;
|
||||
+7
-7
@@ -1,11 +1,11 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS er_incident_occurrences (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
incident_id BIGINT NOT NULL,
|
||||
project_id BIGINT NOT NULL,
|
||||
ingest_key_id BIGINT NULL,
|
||||
occurred_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
|
||||
occurred_at DATETIME(6) NOT NULL,
|
||||
level_raw VARCHAR(32) NOT NULL DEFAULT 'error',
|
||||
severity VARCHAR(16) NOT NULL DEFAULT 'medium',
|
||||
schema_version SMALLINT NOT NULL DEFAULT 1,
|
||||
@@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS er_incident_occurrences (
|
||||
stack_trace TEXT NULL,
|
||||
context_json TEXT NULL,
|
||||
payload_json TEXT NULL,
|
||||
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
CONSTRAINT er_incident_occurrences_incident_fk FOREIGN KEY (incident_id)
|
||||
REFERENCES er_incidents (id)
|
||||
ON UPDATE CASCADE
|
||||
@@ -52,7 +52,7 @@ CREATE INDEX IF NOT EXISTS er_incident_occurrences_request_id_idx
|
||||
ON er_incident_occurrences (request_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS er_incident_state_history (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
incident_id BIGINT NOT NULL,
|
||||
project_id BIGINT NOT NULL,
|
||||
from_state VARCHAR(16) NULL,
|
||||
@@ -60,7 +60,7 @@ CREATE TABLE IF NOT EXISTS er_incident_state_history (
|
||||
changed_by_type VARCHAR(16) NOT NULL,
|
||||
changed_by_ref VARCHAR(128) NOT NULL,
|
||||
change_note TEXT NULL,
|
||||
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
CONSTRAINT er_incident_state_history_incident_fk FOREIGN KEY (incident_id)
|
||||
REFERENCES er_incidents (id)
|
||||
ON UPDATE CASCADE
|
||||
@@ -87,7 +87,7 @@ CREATE INDEX IF NOT EXISTS er_incident_state_history_project_state_time_idx
|
||||
ON er_incident_state_history (project_id, to_state, created_at DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS er_incident_attachments (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
occurrence_id BIGINT NOT NULL,
|
||||
incident_id BIGINT NOT NULL,
|
||||
project_id BIGINT NOT NULL,
|
||||
@@ -97,7 +97,7 @@ CREATE TABLE IF NOT EXISTS er_incident_attachments (
|
||||
size_bytes BIGINT NOT NULL DEFAULT 0,
|
||||
checksum_sha256 CHAR(64) NULL,
|
||||
metadata_json TEXT NULL,
|
||||
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
CONSTRAINT er_incident_attachments_occurrence_fk FOREIGN KEY (occurrence_id)
|
||||
REFERENCES er_incident_occurrences (id)
|
||||
ON UPDATE CASCADE
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
BEGIN;
|
||||
|
||||
DROP INDEX IF EXISTS er_ingest_idempotency_created_idx;
|
||||
DROP INDEX IF EXISTS er_ingest_idempotency_project_created_idx;
|
||||
DROP TABLE IF EXISTS er_ingest_idempotency;
|
||||
|
||||
COMMIT;
|
||||
@@ -1,7 +1,7 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS er_ingest_idempotency (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
ingest_key_id BIGINT NOT NULL,
|
||||
project_id BIGINT NOT NULL,
|
||||
idempotency_key VARCHAR(128) NOT NULL,
|
||||
@@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS er_ingest_idempotency (
|
||||
occurrence_id BIGINT NULL,
|
||||
http_status SMALLINT NOT NULL DEFAULT 200,
|
||||
response_json TEXT NOT NULL,
|
||||
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
CONSTRAINT er_ingest_idempotency_ingest_key_fk FOREIGN KEY (ingest_key_id)
|
||||
REFERENCES er_ingest_keys (id)
|
||||
ON UPDATE CASCADE
|
||||
|
||||
-10
@@ -1,18 +1,8 @@
|
||||
BEGIN;
|
||||
|
||||
DROP INDEX IF EXISTS er_audit_logs_request_id_idx;
|
||||
DROP INDEX IF EXISTS er_audit_logs_project_entity_created_idx;
|
||||
DROP INDEX IF EXISTS er_audit_logs_project_created_idx;
|
||||
DROP TABLE IF EXISTS er_audit_logs;
|
||||
|
||||
DROP TABLE IF EXISTS er_retention_policies;
|
||||
|
||||
DROP INDEX IF EXISTS er_collector_runs_project_status_started_idx;
|
||||
DROP INDEX IF EXISTS er_collector_runs_project_started_idx;
|
||||
DROP INDEX IF EXISTS er_collector_runs_source_started_idx;
|
||||
DROP TABLE IF EXISTS er_collector_runs;
|
||||
|
||||
DROP INDEX IF EXISTS er_collector_sources_project_active_idx;
|
||||
DROP TABLE IF EXISTS er_collector_sources;
|
||||
|
||||
COMMIT;
|
||||
+24
-24
@@ -1,19 +1,19 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS er_collector_sources (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
project_id BIGINT NOT NULL,
|
||||
name VARCHAR(128) NOT NULL,
|
||||
source_type VARCHAR(16) NOT NULL,
|
||||
endpoint_uri VARCHAR(1024) NOT NULL,
|
||||
auth_secret_ref VARCHAR(255) NULL,
|
||||
poll_interval_seconds INTEGER NOT NULL DEFAULT 60,
|
||||
poll_interval_seconds INT NOT NULL DEFAULT 60,
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
last_success_at TIMESTAMP WITHOUT TIME ZONE NULL,
|
||||
last_error_at TIMESTAMP WITHOUT TIME ZONE NULL,
|
||||
last_success_at DATETIME(6) NULL,
|
||||
last_error_at DATETIME(6) NULL,
|
||||
last_error_message TEXT NULL,
|
||||
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
updated_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||
CONSTRAINT er_collector_sources_project_fk FOREIGN KEY (project_id)
|
||||
REFERENCES er_projects (id)
|
||||
ON UPDATE CASCADE
|
||||
@@ -29,19 +29,19 @@ CREATE INDEX IF NOT EXISTS er_collector_sources_project_active_idx
|
||||
ON er_collector_sources (project_id, is_active);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS er_collector_runs (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
collector_source_id BIGINT NOT NULL,
|
||||
project_id BIGINT NOT NULL,
|
||||
triggered_by VARCHAR(16) NOT NULL,
|
||||
started_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
|
||||
finished_at TIMESTAMP WITHOUT TIME ZONE NULL,
|
||||
started_at DATETIME(6) NOT NULL,
|
||||
finished_at DATETIME(6) NULL,
|
||||
status VARCHAR(16) NOT NULL,
|
||||
fetched_count INTEGER NOT NULL DEFAULT 0,
|
||||
accepted_count INTEGER NOT NULL DEFAULT 0,
|
||||
deduplicated_count INTEGER NOT NULL DEFAULT 0,
|
||||
failed_count INTEGER NOT NULL DEFAULT 0,
|
||||
fetched_count INT NOT NULL DEFAULT 0,
|
||||
accepted_count INT NOT NULL DEFAULT 0,
|
||||
deduplicated_count INT NOT NULL DEFAULT 0,
|
||||
failed_count INT NOT NULL DEFAULT 0,
|
||||
error_summary TEXT NULL,
|
||||
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
CONSTRAINT er_collector_runs_source_fk FOREIGN KEY (collector_source_id)
|
||||
REFERENCES er_collector_sources (id)
|
||||
ON UPDATE CASCADE
|
||||
@@ -72,18 +72,18 @@ CREATE INDEX IF NOT EXISTS er_collector_runs_project_status_started_idx
|
||||
ON er_collector_runs (project_id, status, started_at DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS er_retention_policies (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
project_id BIGINT NOT NULL,
|
||||
keep_open_days INTEGER NOT NULL DEFAULT 90,
|
||||
keep_resolved_days INTEGER NOT NULL DEFAULT 30,
|
||||
keep_ignored_days INTEGER NOT NULL DEFAULT 7,
|
||||
keep_attachments_days INTEGER NOT NULL DEFAULT 30,
|
||||
keep_audit_days INTEGER NOT NULL DEFAULT 365,
|
||||
keep_open_days INT NOT NULL DEFAULT 90,
|
||||
keep_resolved_days INT NOT NULL DEFAULT 30,
|
||||
keep_ignored_days INT NOT NULL DEFAULT 7,
|
||||
keep_attachments_days INT NOT NULL DEFAULT 30,
|
||||
keep_audit_days INT NOT NULL DEFAULT 365,
|
||||
delete_mode VARCHAR(16) NOT NULL DEFAULT 'soft',
|
||||
updated_by_type VARCHAR(16) NOT NULL DEFAULT 'system',
|
||||
updated_by_ref VARCHAR(128) NOT NULL DEFAULT 'bootstrap',
|
||||
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
updated_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||
CONSTRAINT er_retention_policies_project_fk FOREIGN KEY (project_id)
|
||||
REFERENCES er_projects (id)
|
||||
ON UPDATE CASCADE
|
||||
@@ -99,7 +99,7 @@ CREATE TABLE IF NOT EXISTS er_retention_policies (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS er_audit_logs (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
project_id BIGINT NOT NULL,
|
||||
actor_type VARCHAR(16) NOT NULL,
|
||||
actor_ref VARCHAR(128) NOT NULL,
|
||||
@@ -110,7 +110,7 @@ CREATE TABLE IF NOT EXISTS er_audit_logs (
|
||||
after_json TEXT NULL,
|
||||
request_id VARCHAR(128) NULL,
|
||||
ip_address VARCHAR(64) NULL,
|
||||
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
CONSTRAINT er_audit_logs_project_fk FOREIGN KEY (project_id)
|
||||
REFERENCES er_projects (id)
|
||||
ON UPDATE CASCADE
|
||||
|
||||
@@ -21,6 +21,6 @@ SELECT
|
||||
TRUE
|
||||
FROM er_projects p
|
||||
WHERE p.slug = 'project-alpha'
|
||||
ON CONFLICT (project_id, name) DO NOTHING;
|
||||
ON DUPLICATE KEY UPDATE endpoint_uri = VALUES(endpoint_uri);
|
||||
|
||||
COMMIT;
|
||||
@@ -9,16 +9,16 @@ INSERT INTO er_projects (slug, name, description, is_active)
|
||||
VALUES
|
||||
('project-alpha', 'Project Alpha', 'Seed project A for passive ingest tests', TRUE),
|
||||
('project-beta', 'Project Beta', 'Seed project B for passive ingest tests', TRUE)
|
||||
ON CONFLICT (slug) DO NOTHING;
|
||||
ON DUPLICATE KEY UPDATE slug = VALUES(slug);
|
||||
|
||||
INSERT INTO er_ingest_keys (project_id, label, token_prefix, token_hash, status)
|
||||
SELECT p.id, 'default', 'tok_pr_a', '6b28a152af86ee5d2a30216c5c25e938c1b9bec58685a735b590c8cbaa005189', 'active'
|
||||
FROM er_projects p WHERE p.slug = 'project-alpha'
|
||||
ON CONFLICT (project_id, label) DO NOTHING;
|
||||
ON DUPLICATE KEY UPDATE label = label;
|
||||
|
||||
INSERT INTO er_ingest_keys (project_id, label, token_prefix, token_hash, status)
|
||||
SELECT p.id, 'default', 'tok_pr_b', '63ca0b7048280893a98adb9e2a7333e431eb217d90b9470312b2f169ca736012', 'active'
|
||||
FROM er_projects p WHERE p.slug = 'project-beta'
|
||||
ON CONFLICT (project_id, label) DO NOTHING;
|
||||
ON DUPLICATE KEY UPDATE label = label;
|
||||
|
||||
COMMIT;
|
||||
Reference in new issue
Block a user