Commit ce423a6a authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Hugo Beauzée-Luyssen

Show: Fix constraing violation on insertion

Due to a bug in the 22->23 migration, if any show were present, it was
impossible to add a new one because the FTS table wasn't empty, causing
constraint violation on insertion.
Fix #242
parent 03064f3f
Pipeline #17192 failed with stage
in 3 minutes and 43 seconds
/*
* Ensure we don't have left over shows in the FTS table while the actual one
* is empty
*/
"CREATE TEMPORARY TABLE " + Show::Table::Name + "_backup"
"("
"id_show INTEGER PRIMARY KEY,"
"title TEXT,"
"nb_episodes UNSIGNED INTEGER,"
"release_date UNSIGNED INTEGER,"
"short_summary TEXT,"
"artwork_mrl TEXT,"
"tvdb_id TEXT,"
"is_present UNSIGNED INTEGER"
")",
"INSERT INTO " + Show::Table::Name + "_backup SELECT * FROM " + Show::Table::Name,
"DROP TABLE " + Show::Table::Name,
"DROP TABLE " + Show::FtsTable::Name,
Show::schema( Show::Table::Name, 26 ),
Show::schema( Show::FtsTable::Name, 26 ),
"INSERT INTO " + Show::Table::Name + " SELECT * FROM " + Show::Table::Name + "_backup",
"DROP TABLE " + Show::Table::Name + "_backup",
Show::trigger( Show::Triggers::InsertFts, 26 ),
Show::trigger( Show::Triggers::DeleteFts, 26 ),
......@@ -656,4 +656,7 @@ TEST_F( DbModel, Upgrade24to25 )
TEST_F( DbModel, Upgrade25to26 )
{
CommonMigrationTest( SRC_DIR "/test/unittest/db_v25.sql" );
auto show = ml->createShow( "new test show" );
ASSERT_NE( nullptr, show );
}
......@@ -137,7 +137,7 @@ INSERT INTO AlbumTrack VALUES(1,1,10057,4,NULL,0,1,0);
INSERT INTO AlbumTrack VALUES(2,2,10057,5,NULL,0,1,0);
INSERT INTO AlbumTrack VALUES(3,3,10057,6,NULL,0,1,0);
INSERT INTO AlbumTrack VALUES(4,4,10057,7,NULL,0,1,0);
INSERT INTO Show VALUES(1,NULL,0,NULL,NULL,NULL,NULL,0);
INSERT INTO ShowFts(rowid, title) VALUES(1,'test show');
INSERT INTO AudioTrack VALUES(1,'mpga',128000,44100,2,'','',1);
INSERT INTO AudioTrack VALUES(2,'mpga',128000,44100,2,'','',2);
INSERT INTO AudioTrack VALUES(3,'mpga',128000,44100,2,'','',3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment