collabrix/backend/scripts/create_kanban_boards_for_channels.py
DGSoft a7ff948e7e Beta Release: Complete Kanban system with auto-save, route persistence, and UI improvements
- 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
2025-12-10 23:17:07 +01:00

70 lines
2.4 KiB
Python
Executable File

#!/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()