Some changes in manage.ts --> 3 user.ts, song.ts, songbook.ts
Aufspaltung auf 3 Dateien, aber man muss noch weiter arbeiten (Task: Von better-sqlite3 --> ORM)
This commit is contained in:
1 parent
d395308c6d
commit
d03ff9d26d
7 files changed
+242
-50
No files matched your search
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The primary key for the `SongBookSongs` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to drop the column `SongBookId` on the `SongBookSongs` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `SongId` on the `SongBookSongs` table. All the data in the column will be lost.
|
||||
- Added the required column `songBookId` to the `SongBookSongs` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `songId` to the `SongBookSongs` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_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
|
||||
);
|
||||
INSERT INTO "new_SongBookSongs" ("songNumber") SELECT "songNumber" FROM "SongBookSongs";
|
||||
DROP TABLE "SongBookSongs";
|
||||
ALTER TABLE "new_SongBookSongs" RENAME TO "SongBookSongs";
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
||||
+7
-10
@@ -1,7 +1,4 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Get a free hosted Postgres database in seconds: `npx create-db`
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client"
|
||||
@@ -24,7 +21,7 @@ model Song {
|
||||
id Int @id @default(autoincrement())
|
||||
title String @unique
|
||||
|
||||
songBookSongs SongBookSongs[]
|
||||
songBooks SongBookSongs[]
|
||||
}
|
||||
|
||||
model SongBook {
|
||||
@@ -32,16 +29,16 @@ model SongBook {
|
||||
title String @unique
|
||||
language String
|
||||
|
||||
songBookSongs SongBookSongs[]
|
||||
songs SongBookSongs[]
|
||||
}
|
||||
|
||||
model SongBookSongs {
|
||||
SongBookId Int
|
||||
SongId Int
|
||||
songBookId Int
|
||||
songId Int
|
||||
songNumber Int
|
||||
|
||||
song Song @relation(fields: [SongId], references: [id], onDelete: Cascade)
|
||||
book SongBook @relation(fields: [SongBookId], references: [id], onDelete: Cascade)
|
||||
song Song @relation(fields: [songId], references: [id], onDelete: Cascade)
|
||||
book SongBook @relation(fields: [songBookId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([SongBookId, SongId])
|
||||
@@id([songBookId, songId])
|
||||
}
|
||||
Reference in new issue
Block a user