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.
36 lines
1.9 KiB
SQL
36 lines
1.9 KiB
SQL
-- GoChat Dashboard Apps Table
|
|
-- Reference: Chatwoot app/models/dashboard_app.rb — P2B M12 spec
|
|
-- Stores custom dashboard widget configurations (iframe embeds) per account/user
|
|
|
|
CREATE TABLE IF NOT EXISTS dashboard_apps (
|
|
id SERIAL PRIMARY KEY,
|
|
title VARCHAR(255) NOT NULL,
|
|
description TEXT DEFAULT '',
|
|
icon VARCHAR(255) DEFAULT '',
|
|
url VARCHAR(512) DEFAULT '',
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
deleted_at TIMESTAMP WITH TIME ZONE
|
|
);
|
|
|
|
ALTER TABLE dashboard_apps ADD COLUMN IF NOT EXISTS account_id INTEGER;
|
|
ALTER TABLE dashboard_apps ADD COLUMN IF NOT EXISTS user_id INTEGER;
|
|
ALTER TABLE dashboard_apps ADD COLUMN IF NOT EXISTS kind VARCHAR(100) DEFAULT 'frame';
|
|
ALTER TABLE dashboard_apps ADD COLUMN IF NOT EXISTS content JSONB DEFAULT '[]';
|
|
ALTER TABLE dashboard_apps ADD COLUMN IF NOT EXISTS active BOOLEAN DEFAULT TRUE;
|
|
|
|
UPDATE dashboard_apps SET account_id = 0 WHERE account_id IS NULL;
|
|
ALTER TABLE dashboard_apps ALTER COLUMN account_id SET NOT NULL;
|
|
ALTER TABLE dashboard_apps ALTER COLUMN description SET DEFAULT '';
|
|
ALTER TABLE dashboard_apps ALTER COLUMN icon SET DEFAULT '';
|
|
ALTER TABLE dashboard_apps ALTER COLUMN url TYPE VARCHAR(512);
|
|
ALTER TABLE dashboard_apps ALTER COLUMN url SET DEFAULT '';
|
|
ALTER TABLE dashboard_apps ALTER COLUMN kind SET DEFAULT 'frame';
|
|
ALTER TABLE dashboard_apps ALTER COLUMN content SET DEFAULT '[]';
|
|
ALTER TABLE dashboard_apps ALTER COLUMN active SET DEFAULT TRUE;
|
|
ALTER TABLE dashboard_apps ALTER COLUMN active SET NOT NULL;
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_dashboard_apps_account_id ON dashboard_apps(account_id) WHERE deleted_at IS NULL;
|
|
CREATE INDEX IF NOT EXISTS idx_dashboard_apps_user_id ON dashboard_apps(user_id) WHERE deleted_at IS NULL AND user_id IS NOT NULL;
|
|
CREATE INDEX IF NOT EXISTS idx_dashboard_apps_deleted_at ON dashboard_apps(deleted_at);
|