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.
67 lines
2.8 KiB
SQL
67 lines
2.8 KiB
SQL
CREATE TABLE IF NOT EXISTS csat_survey_responses (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
created_at TIMESTAMPTZ,
|
|
updated_at TIMESTAMPTZ,
|
|
deleted_at TIMESTAMPTZ,
|
|
account_id BIGINT NOT NULL,
|
|
conversation_id BIGINT NOT NULL,
|
|
contact_id BIGINT,
|
|
message_id BIGINT,
|
|
assigned_agent_id BIGINT,
|
|
rating INTEGER NOT NULL,
|
|
feedback_message TEXT,
|
|
csat_review_notes TEXT,
|
|
review_notes_updated_by_id BIGINT,
|
|
review_notes_updated_at TIMESTAMPTZ
|
|
);
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_csat_survey_responses_message_id
|
|
ON csat_survey_responses (message_id)
|
|
WHERE message_id IS NOT NULL AND deleted_at IS NULL;
|
|
CREATE INDEX IF NOT EXISTS idx_csat_survey_responses_account_id ON csat_survey_responses (account_id);
|
|
CREATE INDEX IF NOT EXISTS idx_csat_survey_responses_conversation_id ON csat_survey_responses (conversation_id);
|
|
CREATE INDEX IF NOT EXISTS idx_csat_survey_responses_contact_id ON csat_survey_responses (contact_id);
|
|
CREATE INDEX IF NOT EXISTS idx_csat_survey_responses_assigned_agent_id ON csat_survey_responses (assigned_agent_id);
|
|
CREATE INDEX IF NOT EXISTS idx_csat_survey_responses_review_notes_updated_by_id ON csat_survey_responses (review_notes_updated_by_id);
|
|
CREATE INDEX IF NOT EXISTS idx_csat_survey_responses_deleted_at ON csat_survey_responses (deleted_at);
|
|
|
|
CREATE TABLE IF NOT EXISTS bot_rules (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
created_at TIMESTAMPTZ,
|
|
updated_at TIMESTAMPTZ,
|
|
deleted_at TIMESTAMPTZ,
|
|
agent_bot_id BIGINT NOT NULL,
|
|
account_id BIGINT NOT NULL,
|
|
name VARCHAR(255) NOT NULL,
|
|
description TEXT,
|
|
event_name VARCHAR(100) NOT NULL,
|
|
conditions JSONB DEFAULT '[]'::jsonb,
|
|
actions JSONB DEFAULT '[]'::jsonb,
|
|
status VARCHAR(20) DEFAULT 'active'
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_bot_rules_agent_bot_id ON bot_rules (agent_bot_id);
|
|
CREATE INDEX IF NOT EXISTS idx_bot_rules_account_id ON bot_rules (account_id);
|
|
CREATE INDEX IF NOT EXISTS idx_bot_rules_event_name ON bot_rules (event_name);
|
|
CREATE INDEX IF NOT EXISTS idx_bot_rules_deleted_at ON bot_rules (deleted_at);
|
|
|
|
CREATE TABLE IF NOT EXISTS bot_trigger_configs (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
created_at TIMESTAMPTZ,
|
|
updated_at TIMESTAMPTZ,
|
|
deleted_at TIMESTAMPTZ,
|
|
agent_bot_id BIGINT NOT NULL,
|
|
account_id BIGINT NOT NULL,
|
|
name VARCHAR(255) NOT NULL,
|
|
description TEXT,
|
|
event_name VARCHAR(100) NOT NULL,
|
|
conditions JSONB DEFAULT '[]'::jsonb,
|
|
query_operator VARCHAR(10) DEFAULT 'and',
|
|
active BOOLEAN DEFAULT true
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_bot_trigger_configs_agent_bot_id ON bot_trigger_configs (agent_bot_id);
|
|
CREATE INDEX IF NOT EXISTS idx_bot_trigger_configs_account_id ON bot_trigger_configs (account_id);
|
|
CREATE INDEX IF NOT EXISTS idx_bot_trigger_configs_event_name ON bot_trigger_configs (event_name);
|
|
CREATE INDEX IF NOT EXISTS idx_bot_trigger_configs_deleted_at ON bot_trigger_configs (deleted_at);
|