-- Migration 010: Remove template_id columns and related indexes
-- This migration removes template_id references from git-integration tables

-- Drop indexes that reference template_id first
DROP INDEX IF EXISTS idx_github_repos_template_id;
DROP INDEX IF EXISTS idx_github_repos_template_user;
DROP INDEX IF EXISTS idx_feature_mappings_template_user;

-- Remove template_id column from github_repositories table
ALTER TABLE IF EXISTS github_repositories 
  DROP COLUMN IF EXISTS template_id;

-- Remove template_id column from feature_codebase_mappings table
ALTER TABLE IF EXISTS feature_codebase_mappings 
  DROP COLUMN IF EXISTS template_id;

-- Note: This migration removes the template_id foreign key relationships
-- The tables will now rely on user_id for ownership tracking
