feat(backend): migrations Postgres testées (users, devices, resources, operations, ocr_jobs) + migrate au boot
- golang-migrate embarqué via embed (db/migrations/*.sql), MigrateDatabase(url) au boot
- ids TEXT 32-hex avec CHECK ~ '^[0-9a-f]{32}$' ; operations idempotentes UNIQUE(device_id, operation_id)
- harness db/migrations_test.go (up → assertions schéma → down, skip si PG indisponible)
- DB dev fraîche vaultdrop_dev (la DB vaultdrop héberge un prototype V2 abandonné)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE operations (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
device_id TEXT NOT NULL REFERENCES devices(device_id) ON DELETE CASCADE,
|
||||
operation_id TEXT NOT NULL CHECK (operation_id ~ '^[0-9a-f]{32}$'),
|
||||
op_type TEXT NOT NULL,
|
||||
payload JSONB NOT NULL,
|
||||
status TEXT NOT NULL DEFAULT 'applied' CHECK (status IN ('applied', 'failed')),
|
||||
error_code TEXT,
|
||||
applied_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
CONSTRAINT operations_unique_per_device UNIQUE (device_id, operation_id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_operations_device_created ON operations(device_id, created_at);
|
||||
Reference in New Issue
Block a user