[ongeki]fix DB table ongeki_user_rival wrong foreign key and rename...
This PR is to fix the wrong foreign key on the database table ongeki_user_rival
and rename a field of UserRival.
Fix the wrong foreign key
This foreign key is correct before commit 687df8f57b59e1a06393f87f3dd734f5a9b3c732, but after that it is wrong and inappropriate. Because of this wrong foreign key, users can't execute sql to add records manually, but I don’t know why framework Spring is still able to add records normally and pass the unit test.
Add more test cases for ongeki rival.
I wrote migration scripts for sqlite and mariadb , mysql is copied from mariadb. sqlite and mariadb both pass unit tests but mysql not take a test.
In sqlite , migration will create new table and copy from old table, old table renamed to ongeki_user_rival_old
;
In mariadb/mysql , migration will modify foreign key directly and no backup;
ongeki_user_rival before fix (Sqlite):
CREATE TABLE "ongeki_user_rival_old" (
"id" INTEGER NOT NULL,
"rival_user_id" BIGINT,
"user_id" BIGINT,
FOREIGN KEY("user_id") REFERENCES "ongeki_user_data"("id") ON DELETE CASCADE,
FOREIGN KEY("rival_user_id") REFERENCES "ongeki_user_data"("id") ON DELETE CASCADE,
PRIMARY KEY("id" AUTOINCREMENT),
CONSTRAINT "ongeki_user_rival_uq" UNIQUE("user_id","rival_user_id") ON CONFLICT REPLACE
)
ongeki_user_rival after fix (Sqlite):
CREATE TABLE "ongeki_user_rival" (
"id" INTEGER NOT NULL,
"rival_user_ext_id" BIGINT,
"user_id" BIGINT,
FOREIGN KEY("user_id") REFERENCES "ongeki_user_data"("id") ON DELETE CASCADE,
FOREIGN KEY("rival_user_ext_id") REFERENCES "sega_card"("ext_id") ON DELETE CASCADE,
PRIMARY KEY("id" AUTOINCREMENT),
CONSTRAINT "ongeki_user_rival_uq" UNIQUE("user_id","rival_user_ext_id") ON CONFLICT REPLACE
)
Rename field
And I rename UserRival.rivalUserId -> UserRival.rivalUserExtId for programmers to avoid the confusion of aimeId
/userId
/extId
.
Please take a code review.