migrate auth db to sql server

This commit is contained in:
2022-08-23 15:06:55 +01:00
parent 4b38849f1d
commit 69a81e482f
13 changed files with 194 additions and 91 deletions
@@ -1,57 +1,61 @@
-- CreateTable
CREATE TABLE `accounts` (
`id` VARCHAR(191) NOT NULL,
`user_id` VARCHAR(191) NOT NULL,
`type` VARCHAR(191) NOT NULL,
`provider` VARCHAR(191) NOT NULL,
`provider_account_id` VARCHAR(191) NOT NULL,
`refresh_token` TEXT NULL,
`access_token` TEXT NULL,
`expires_at` INTEGER NULL,
`token_type` VARCHAR(191) NULL,
`scope` VARCHAR(191) NULL,
`id_token` TEXT NULL,
`session_state` VARCHAR(191) NULL,
-- SQLINES LICENSE FOR EVALUATION USE ONLY
CREATE TABLE accounts (
id VARCHAR(191) NOT NULL,
user_id VARCHAR(191) NOT NULL,
type VARCHAR(191) NOT NULL,
provider VARCHAR(191) NOT NULL,
provider_account_id VARCHAR(191) NOT NULL,
refresh_token VARCHAR(max) NULL,
access_token VARCHAR(max) NULL,
expires_at INTEGER NULL,
token_type VARCHAR(191) NULL,
scope VARCHAR(191) NULL,
id_token VARCHAR(max) NULL,
session_state VARCHAR(191) NULL,
UNIQUE INDEX `accounts_provider_provider_account_id_key`(`provider`, `provider_account_id`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CONSTRAINT accounts_provider_provider_account_id_key UNIQUE (provider, provider_account_id),
PRIMARY KEY (id)
)
-- CreateTable
CREATE TABLE `sessions` (
`id` VARCHAR(191) NOT NULL,
`session_token` VARCHAR(191) NOT NULL,
`user_id` VARCHAR(191) NOT NULL,
`expires` DATETIME(3) NOT NULL,
-- SQLINES LICENSE FOR EVALUATION USE ONLY
CREATE TABLE sessions (
id VARCHAR(191) NOT NULL,
session_token VARCHAR(191) NOT NULL,
user_id VARCHAR(191) NOT NULL,
expires DATETIME2(3) NOT NULL,
UNIQUE INDEX `sessions_session_token_key`(`session_token`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CONSTRAINT sessions_session_token_key UNIQUE (session_token),
PRIMARY KEY (id)
)
-- CreateTable
CREATE TABLE `users` (
`id` VARCHAR(191) NOT NULL,
`name` VARCHAR(191) NULL,
`email` VARCHAR(191) NULL,
`email_verified` DATETIME(3) NULL,
`image` VARCHAR(191) NULL,
-- SQLINES LICENSE FOR EVALUATION USE ONLY
CREATE TABLE users (
id VARCHAR(191) NOT NULL,
name VARCHAR(191) NULL,
email VARCHAR(191) NULL,
email_verified DATETIME2(3) NULL,
image VARCHAR(191) NULL,
UNIQUE INDEX `users_email_key`(`email`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CONSTRAINT users_email_key UNIQUE (email),
PRIMARY KEY (id)
)
-- CreateTable
CREATE TABLE `verificationtokens` (
`identifier` VARCHAR(191) NOT NULL,
`token` VARCHAR(191) NOT NULL,
`expires` DATETIME(3) NOT NULL,
-- SQLINES LICENSE FOR EVALUATION USE ONLY
CREATE TABLE verificationtokens (
identifier VARCHAR(191) NOT NULL,
token VARCHAR(191) NOT NULL,
expires DATETIME2(3) NOT NULL,
UNIQUE INDEX `verificationtokens_token_key`(`token`),
UNIQUE INDEX `verificationtokens_identifier_token_key`(`identifier`, `token`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CONSTRAINT verificationtokens_token_key UNIQUE (token),
CONSTRAINT verificationtokens_identifier_token_key UNIQUE (identifier, token)
)
-- AddForeignKey
ALTER TABLE `accounts` ADD CONSTRAINT `accounts_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE accounts ADD CONSTRAINT accounts_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `sessions` ADD CONSTRAINT `sessions_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE sessions ADD CONSTRAINT sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ON UPDATE CASCADE;
+61
View File
@@ -0,0 +1,61 @@
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model Account {
id String @id @default(cuid())
userId String @map("user_id")
type String
provider String
providerAccountId String @map("provider_account_id")
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@map("accounts")
}
model Session {
id String @id @default(cuid())
sessionToken String @unique @map("session_token")
userId String @map("user_id")
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map("sessions")
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime? @map("email_verified")
image String?
accounts Account[]
sessions Session[]
@@map("users")
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
@@map("verificationtokens")
}
+16 -17
View File
@@ -1,27 +1,26 @@
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
provider = "sqlserver"
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
}
model Account {
id String @id @default(cuid())
userId String @map("user_id")
type String
provider String
providerAccountId String @map("provider_account_id")
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
session_state String?
id String @id @default(cuid())
userId String @map("user_id")
type String
provider String
providerAccountId String
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)