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.
59 lines
2.2 KiB
SQL
59 lines
2.2 KiB
SQL
CREATE TABLE IF NOT EXISTS teams (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
created_at TIMESTAMPTZ,
|
|
updated_at TIMESTAMPTZ,
|
|
deleted_at TIMESTAMPTZ,
|
|
account_id BIGINT NOT NULL,
|
|
name VARCHAR(255) NOT NULL,
|
|
description TEXT,
|
|
allow_auto_assignment BOOLEAN DEFAULT true
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_teams_account_id ON teams (account_id);
|
|
CREATE INDEX IF NOT EXISTS idx_teams_deleted_at ON teams (deleted_at);
|
|
|
|
CREATE TABLE IF NOT EXISTS team_members (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
created_at TIMESTAMPTZ,
|
|
updated_at TIMESTAMPTZ,
|
|
deleted_at TIMESTAMPTZ,
|
|
team_id BIGINT NOT NULL,
|
|
user_id BIGINT NOT NULL,
|
|
availability_status VARCHAR(50) DEFAULT 'offline'
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_team_members_team_id ON team_members (team_id);
|
|
CREATE INDEX IF NOT EXISTS idx_team_members_user_id ON team_members (user_id);
|
|
CREATE INDEX IF NOT EXISTS idx_team_members_deleted_at ON team_members (deleted_at);
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_team_members_team_user ON team_members (team_id, user_id) WHERE deleted_at IS NULL;
|
|
|
|
CREATE TABLE IF NOT EXISTS campaigns (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
created_at TIMESTAMPTZ,
|
|
updated_at TIMESTAMPTZ,
|
|
deleted_at TIMESTAMPTZ,
|
|
account_id BIGINT NOT NULL,
|
|
inbox_id BIGINT NOT NULL,
|
|
sender_id BIGINT,
|
|
display_id BIGINT NOT NULL,
|
|
title VARCHAR(255) NOT NULL,
|
|
message TEXT NOT NULL,
|
|
description TEXT,
|
|
campaign_status VARCHAR(50) DEFAULT 'active',
|
|
campaign_type VARCHAR(50) NOT NULL,
|
|
audience JSONB DEFAULT '{}'::jsonb,
|
|
trigger_rules JSONB DEFAULT '{}'::jsonb,
|
|
template_params JSONB DEFAULT '{}'::jsonb,
|
|
scheduled_at TIMESTAMPTZ,
|
|
enabled BOOLEAN DEFAULT true,
|
|
trigger_only_during_business_hours BOOLEAN DEFAULT false
|
|
);
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_campaign_display ON campaigns (display_id);
|
|
CREATE INDEX IF NOT EXISTS idx_campaigns_account_id ON campaigns (account_id);
|
|
CREATE INDEX IF NOT EXISTS idx_campaigns_inbox_id ON campaigns (inbox_id);
|
|
CREATE INDEX IF NOT EXISTS idx_campaigns_sender_id ON campaigns (sender_id);
|
|
CREATE INDEX IF NOT EXISTS idx_campaigns_campaign_status ON campaigns (campaign_status);
|
|
CREATE INDEX IF NOT EXISTS idx_campaigns_scheduled_at ON campaigns (scheduled_at);
|
|
CREATE INDEX IF NOT EXISTS idx_campaigns_deleted_at ON campaigns (deleted_at);
|