mirror of
https://github.com/OHV-IT/collabrix.git
synced 2025-12-15 16:48:36 +01:00
- Added complete Kanban board functionality with drag-and-drop - Implemented auto-save for Kanban card editing (no more edit button) - Added route persistence to remember last visited page on reload - Improved Kanban UI design with slimmer borders and compact layout - Added checklist functionality for Kanban cards - Enhanced file upload and direct messaging features - Improved authentication and user management - Added toast notifications system - Various UI/UX improvements and bug fixes
115 lines
4.2 KiB
Python
115 lines
4.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Migration script to create Kanban tables
|
|
"""
|
|
import sys
|
|
import os
|
|
|
|
# Add parent directory to path to import app modules
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from sqlalchemy import text
|
|
from app.database import engine
|
|
|
|
|
|
def migrate():
|
|
"""Create Kanban tables"""
|
|
with engine.connect() as conn:
|
|
# Check if tables already exist
|
|
result = conn.execute(text("""
|
|
SELECT table_name
|
|
FROM information_schema.tables
|
|
WHERE table_schema = 'public'
|
|
AND table_name IN ('kanban_board', 'kanban_column', 'kanban_card')
|
|
"""))
|
|
|
|
existing_tables = [row[0] for row in result.fetchall()]
|
|
|
|
if 'kanban_board' in existing_tables:
|
|
print("✅ Kanban tables already exist")
|
|
return
|
|
|
|
print("🚀 Creating Kanban tables...")
|
|
|
|
# Create kanban_board table
|
|
conn.execute(text("""
|
|
CREATE TABLE kanban_board (
|
|
id SERIAL PRIMARY KEY,
|
|
channel_id INTEGER NOT NULL REFERENCES channel(id) ON DELETE CASCADE,
|
|
name VARCHAR(255) NOT NULL DEFAULT 'Kanban Board',
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
|
)
|
|
"""))
|
|
|
|
# Create kanban_column table
|
|
conn.execute(text("""
|
|
CREATE TABLE kanban_column (
|
|
id SERIAL PRIMARY KEY,
|
|
board_id INTEGER NOT NULL REFERENCES kanban_board(id) ON DELETE CASCADE,
|
|
name VARCHAR(255) NOT NULL,
|
|
position INTEGER NOT NULL DEFAULT 0,
|
|
color VARCHAR(7),
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
|
)
|
|
"""))
|
|
|
|
# Create kanban_card table
|
|
conn.execute(text("""
|
|
CREATE TABLE kanban_card (
|
|
id SERIAL PRIMARY KEY,
|
|
column_id INTEGER NOT NULL REFERENCES kanban_column(id) ON DELETE CASCADE,
|
|
title VARCHAR(500) NOT NULL,
|
|
description TEXT,
|
|
assignee_id INTEGER REFERENCES "user"(id),
|
|
position INTEGER NOT NULL DEFAULT 0,
|
|
due_date TIMESTAMP WITH TIME ZONE,
|
|
priority VARCHAR(20) DEFAULT 'medium',
|
|
labels TEXT,
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
|
)
|
|
"""))
|
|
|
|
# Create indexes for better performance
|
|
conn.execute(text("CREATE INDEX idx_kanban_board_channel_id ON kanban_board(channel_id)"))
|
|
conn.execute(text("CREATE INDEX idx_kanban_column_board_id ON kanban_column(board_id)"))
|
|
conn.execute(text("CREATE INDEX idx_kanban_card_column_id ON kanban_card(column_id)"))
|
|
conn.execute(text("CREATE INDEX idx_kanban_card_assignee_id ON kanban_card(assignee_id)"))
|
|
|
|
# Create trigger to update updated_at timestamp
|
|
conn.execute(text("""
|
|
CREATE OR REPLACE FUNCTION update_updated_at_column()
|
|
RETURNS TRIGGER AS $$
|
|
BEGIN
|
|
NEW.updated_at = CURRENT_TIMESTAMP;
|
|
RETURN NEW;
|
|
END;
|
|
$$ language 'plpgsql';
|
|
"""))
|
|
|
|
conn.execute(text("""
|
|
CREATE TRIGGER update_kanban_board_updated_at
|
|
BEFORE UPDATE ON kanban_board
|
|
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
|
"""))
|
|
|
|
conn.execute(text("""
|
|
CREATE TRIGGER update_kanban_column_updated_at
|
|
BEFORE UPDATE ON kanban_column
|
|
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
|
"""))
|
|
|
|
conn.execute(text("""
|
|
CREATE TRIGGER update_kanban_card_updated_at
|
|
BEFORE UPDATE ON kanban_card
|
|
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
|
"""))
|
|
|
|
conn.commit()
|
|
print("✅ Kanban tables created successfully!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
migrate() |