55 lines
1.8 KiB
SQL
55 lines
1.8 KiB
SQL
/*
|
|
Warnings:
|
|
|
|
- You are about to drop the column `email` on the `User` table. All the data in the column will be lost.
|
|
- You are about to drop the column `firstname` on the `User` table. All the data in the column will be lost.
|
|
- You are about to drop the column `lastname` on the `User` table. All the data in the column will be lost.
|
|
|
|
*/
|
|
-- CreateTable
|
|
CREATE TABLE "Song" (
|
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
"title" TEXT NOT NULL
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "SongBook" (
|
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
"title" TEXT NOT NULL,
|
|
"language" TEXT NOT NULL
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "SongBookSongs" (
|
|
"SongBookId" INTEGER NOT NULL,
|
|
"SongId" INTEGER NOT NULL,
|
|
"songNumber" INTEGER NOT NULL,
|
|
|
|
PRIMARY KEY ("SongBookId", "SongId"),
|
|
CONSTRAINT "SongBookSongs_SongId_fkey" FOREIGN KEY ("SongId") REFERENCES "Song" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
CONSTRAINT "SongBookSongs_SongBookId_fkey" FOREIGN KEY ("SongBookId") REFERENCES "SongBook" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
);
|
|
|
|
-- RedefineTables
|
|
PRAGMA defer_foreign_keys=ON;
|
|
PRAGMA foreign_keys=OFF;
|
|
CREATE TABLE "new_User" (
|
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
"username" TEXT NOT NULL,
|
|
"password" TEXT NOT NULL,
|
|
"role" TEXT NOT NULL DEFAULT 'user',
|
|
"name" TEXT
|
|
);
|
|
INSERT INTO "new_User" ("id", "password", "role", "username") SELECT "id", "password", "role", "username" FROM "User";
|
|
DROP TABLE "User";
|
|
ALTER TABLE "new_User" RENAME TO "User";
|
|
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
|
|
PRAGMA foreign_keys=ON;
|
|
PRAGMA defer_foreign_keys=OFF;
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "Song_title_key" ON "Song"("title");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "SongBook_title_key" ON "SongBook"("title");
|