Skip to content

Commit

Permalink
feat(server): add User and AuthenticationMethod tables
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlatz committed Feb 27, 2024
1 parent 598b6bf commit fda4284
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- CreateTable
CREATE TABLE `AuthenticationMethod` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`userId` INTEGER NOT NULL,
`provider` VARCHAR(191) NOT NULL,
`externalId` VARCHAR(191) NOT NULL,
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`updatedAt` DATETIME(3) NULL,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `User` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`pilotName` VARCHAR(191) NOT NULL,
`lastLoggedAt` DATETIME(3) NOT NULL,
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`updatedAt` DATETIME(3) NULL,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `AuthenticationMethod` ADD CONSTRAINT `AuthenticationMethod_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
19 changes: 19 additions & 0 deletions server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ datasource db {
url = env("DATABASE_URL")
}

model AuthenticationMethod {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
provider String
externalId String
createdAt DateTime @default(now())
updatedAt DateTime?
}

model Event {
id Int @id @default(autoincrement())
ship Ship @relation(fields: [shipId], references: [id])
Expand All @@ -31,3 +41,12 @@ model Ship {
updatedAt DateTime?
events Event[]
}

model User {
id Int @id @default(autoincrement())
pilotName String
lastLoggedAt DateTime
createdAt DateTime @default(now())
updatedAt DateTime?
authenticationMethods AuthenticationMethod[]
}

0 comments on commit fda4284

Please sign in to comment.