#!/usr/bin/env python3 """ Script to create Kanban boards for all existing channels that don't have one yet. This ensures all channels have their own Kanban board with the 4 standard columns. """ import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from sqlmodel import Session, select from app.database import engine from app.models import Channel, KanbanBoard, KanbanColumn def create_kanban_boards_for_existing_channels(): """Create Kanban boards for all channels that don't have one""" with Session(engine) as session: # Get all channels channels = session.exec(select(Channel)).all() print(f"Found {len(channels)} channels") # Check which channels already have boards boards = session.exec(select(KanbanBoard)).all() channels_with_boards = set([board.channel_id for board in boards]) channels_without_boards = [ channel for channel in channels if channel.id not in channels_with_boards ] print(f"Found {len(channels_without_boards)} channels without Kanban boards") default_columns = [ ("ToDo", 0), ("In Progress", 1), ("Waiting", 2), ("Done", 3) ] for channel in channels_without_boards: print(f"Creating Kanban board for channel: {channel.name} (ID: {channel.id})") # Create the board kanban_board = KanbanBoard( channel_id=channel.id, name=f"Kanban Board" ) session.add(kanban_board) session.commit() session.refresh(kanban_board) # Create the 4 standard columns for name, position in default_columns: column = KanbanColumn( board_id=kanban_board.id, name=name, position=position ) session.add(column) session.commit() print(f" āœ“ Created Kanban board with 4 standard columns for channel {channel.name}") print(f"\nāœ… Successfully created Kanban boards for {len(channels_without_boards)} channels") print("All channels now have their own Kanban board with the 4 standard columns: ToDo, In Progress, Waiting, Done") if __name__ == "__main__": create_kanban_boards_for_existing_channels()