import java.sql.*; /** Additive migration, explicitly guarded to the Chengzhi database. */ public class TtsModelMigration { static void add(Connection c,String table,String column,String type)throws Exception{ if(CorpusDatabase.count(c,"SELECT COUNT(*) FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name=? AND column_name=?",table,column)==0){ try(Statement s=c.createStatement()){s.executeUpdate("ALTER TABLE "+table+" ADD COLUMN "+column+" "+type);} System.out.println("COLUMN_ADDED "+table+"."+column); } } public static void main(String[] args)throws Exception{ CorpusDatabase.init();try(Connection c=CorpusDatabase.connect()){ long tasks=CorpusDatabase.count(c,"SELECT COUNT(*) FROM tts_synthesize_task"),corpus=CorpusDatabase.count(c,"SELECT COUNT(*) FROM tts_corpus_info"); add(c,"tts_synthesize_task","model","varchar(32) NOT NULL DEFAULT 'xfyun'"); add(c,"tts_synthesize_task","instructions","varchar(1000) NULL"); add(c,"tts_corpus_info","model","varchar(32) NOT NULL DEFAULT 'xfyun'"); if(tasks!=CorpusDatabase.count(c,"SELECT COUNT(*) FROM tts_synthesize_task")||corpus!=CorpusDatabase.count(c,"SELECT COUNT(*) FROM tts_corpus_info"))throw new IllegalStateException("Row count changed"); System.out.println("MODEL_MIGRATION_OK tasks="+tasks+" corpus="+corpus+"; existing audio paths unchanged"); }System.exit(0); } }