mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-12 01:37:40 +02:00
Add a new SQL script and documentation to guide users in creating the `announcements` table in their production environment to resolve the "relation does not exist" error. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e437ffed-c31b-44eb-9fd5-b6f9faa8e7ce Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/e437ffed-c31b-44eb-9fd5-b6f9faa8e7ce/biGr9ER
42 lines
1.6 KiB
SQL
42 lines
1.6 KiB
SQL
-- Commandes à exécuter DIRECTEMENT dans votre conteneur Docker
|
|
-- Copiez et collez ces commandes une par une dans votre terminal
|
|
|
|
-- 1. Entrer dans le conteneur
|
|
-- docker exec -it logiflow-logiflow-1 /bin/bash
|
|
|
|
-- 2. Une fois dans le conteneur, exécuter cette commande SQL :
|
|
-- psql $DATABASE_URL
|
|
|
|
-- 3. Coller ce SQL dans psql :
|
|
|
|
CREATE TABLE IF NOT EXISTS announcements (
|
|
id SERIAL PRIMARY KEY,
|
|
title VARCHAR(255) NOT NULL,
|
|
content TEXT NOT NULL,
|
|
priority VARCHAR(20) NOT NULL DEFAULT 'normal',
|
|
author_id VARCHAR(255) NOT NULL,
|
|
group_id INTEGER,
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
);
|
|
|
|
ALTER TABLE announcements ADD CONSTRAINT announcements_priority_check
|
|
CHECK (priority IN ('normal', 'important', 'urgent'));
|
|
|
|
ALTER TABLE announcements ADD CONSTRAINT announcements_author_id_fkey
|
|
FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE;
|
|
|
|
ALTER TABLE announcements ADD CONSTRAINT announcements_group_id_fkey
|
|
FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE;
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_announcements_priority ON announcements(priority);
|
|
CREATE INDEX IF NOT EXISTS idx_announcements_created_at ON announcements(created_at DESC);
|
|
CREATE INDEX IF NOT EXISTS idx_announcements_author_id ON announcements(author_id);
|
|
CREATE INDEX IF NOT EXISTS idx_announcements_group_id ON announcements(group_id);
|
|
|
|
-- Vérification
|
|
SELECT 'SUCCESS: Table announcements créée avec succès!' as result;
|
|
SELECT COUNT(*) as nb_colonnes FROM information_schema.columns WHERE table_name = 'announcements';
|
|
|
|
-- 4. Taper \q pour quitter psql
|
|
-- 5. Taper exit pour quitter le conteneur |