Restructure the monorepo into clear top-level directories: - backend/: Go module root (cmd, internal, pkg, configs, migrations, docs/swagger, scripts, tests, go.mod, Makefile, .air.toml) - deploy/: Docker (Dockerfile, docker-compose*), quickstart, fluentd - docs/: project documentation + reports/ (moved from repo root) - AGENTS.md: new AI coding-agent guide at repo root Update all references to the new layout: - Dockerfile: COPY backend/go.mod, COPY backend/ (context = repo root) - docker-compose files: context ../.., dockerfile deploy/docker/Dockerfile, env_file ../../.env, volume mounts ../../backend:/app - deploy/quickstart/compose.yaml: dockerfile deploy/docker/Dockerfile - CI: working-directory: backend for go commands, file deploy/docker/Dockerfile, coverage path backend/coverage.out, health_check backend/scripts/ - backend/Makefile: docker target uses -f ../deploy/docker/Dockerfile ../ - README: architecture tree, quickstart, config paths updated Move root stray scripts (rename_models.*, run_m11_tests.sh, verify_build.sh, gorm_bool_main.go) to backend/scripts/legacy/. All moves via git mv to preserve history. Build, vet, SQLite tests, and docker compose config verified.
52 lines
2.0 KiB
SQL
52 lines
2.0 KiB
SQL
CREATE TABLE IF NOT EXISTS automation_rules (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
created_at TIMESTAMPTZ,
|
|
updated_at TIMESTAMPTZ,
|
|
deleted_at TIMESTAMPTZ,
|
|
account_id BIGINT NOT NULL,
|
|
event_name VARCHAR(100) NOT NULL,
|
|
name VARCHAR(255) NOT NULL,
|
|
description TEXT,
|
|
active BOOLEAN DEFAULT true,
|
|
active_at TIMESTAMPTZ,
|
|
inactive_at TIMESTAMPTZ,
|
|
conditions JSONB DEFAULT '[]'::jsonb,
|
|
actions JSONB DEFAULT '[]'::jsonb
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_automation_rules_account_id ON automation_rules (account_id);
|
|
CREATE INDEX IF NOT EXISTS idx_automation_rules_event_name ON automation_rules (event_name);
|
|
CREATE INDEX IF NOT EXISTS idx_automation_rules_active_at ON automation_rules (active_at);
|
|
CREATE INDEX IF NOT EXISTS idx_automation_rules_inactive_at ON automation_rules (inactive_at);
|
|
CREATE INDEX IF NOT EXISTS idx_automation_rules_deleted_at ON automation_rules (deleted_at);
|
|
|
|
CREATE TABLE IF NOT EXISTS macros (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
created_at TIMESTAMPTZ,
|
|
updated_at TIMESTAMPTZ,
|
|
deleted_at TIMESTAMPTZ,
|
|
account_id BIGINT NOT NULL,
|
|
name VARCHAR(255) NOT NULL,
|
|
actions JSONB DEFAULT '[]'::jsonb,
|
|
visibility INTEGER DEFAULT 0,
|
|
active BOOLEAN NOT NULL DEFAULT true,
|
|
created_by_id BIGINT NOT NULL,
|
|
updated_by_id BIGINT NOT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_macros_account_id ON macros (account_id);
|
|
CREATE INDEX IF NOT EXISTS idx_macros_created_by_id ON macros (created_by_id);
|
|
CREATE INDEX IF NOT EXISTS idx_macros_updated_by_id ON macros (updated_by_id);
|
|
CREATE INDEX IF NOT EXISTS idx_macros_deleted_at ON macros (deleted_at);
|
|
|
|
CREATE TABLE IF NOT EXISTS macro_executions (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
macro_id BIGINT NOT NULL,
|
|
conversation_id BIGINT NOT NULL,
|
|
executed_by_id BIGINT NOT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_macro_executions_macro_id ON macro_executions (macro_id);
|
|
CREATE INDEX IF NOT EXISTS idx_macro_executions_conversation_id ON macro_executions (conversation_id);
|
|
CREATE INDEX IF NOT EXISTS idx_macro_executions_executed_by_id ON macro_executions (executed_by_id);
|