Skip to content

Commit d6b8e3f

Browse files
committed
feat: remove Configuration model and update User model to use full name
1 parent 4345fb1 commit d6b8e3f

7 files changed

Lines changed: 16 additions & 154 deletions

File tree

express/prisma/migrations/20260216155800_init/migration.sql renamed to express/prisma/migrations/20260311045759_init/migration.sql

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,11 @@
1-
-- CreateTable
2-
CREATE TABLE "configurations" (
3-
"id" TEXT NOT NULL,
4-
"key" TEXT NOT NULL,
5-
"value" TEXT NOT NULL,
6-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
7-
"updatedAt" TIMESTAMP(3) NOT NULL,
8-
9-
CONSTRAINT "configurations_pkey" PRIMARY KEY ("id")
10-
);
11-
121
-- CreateTable
132
CREATE TABLE "users" (
143
"id" TEXT NOT NULL,
154
"email" TEXT NOT NULL,
165
"password" TEXT NOT NULL,
17-
"firstName" TEXT NOT NULL,
18-
"lastName" TEXT NOT NULL,
19-
"avatar" TEXT,
20-
"bio" TEXT,
21-
"phone" TEXT,
22-
"googleId" VARCHAR(255),
23-
"facebookId" VARCHAR(255),
24-
"emailVerifiedAt" TIMESTAMP(3),
25-
"emailVerificationCode" VARCHAR(64),
6+
"name" TEXT NOT NULL,
267
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
278
"updatedAt" TIMESTAMP(3) NOT NULL,
28-
"locationId" TEXT,
299

3010
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
3111
);
@@ -45,9 +25,6 @@ CREATE TABLE "personal_access_tokens" (
4525
CONSTRAINT "personal_access_tokens_pkey" PRIMARY KEY ("id")
4626
);
4727

48-
-- CreateIndex
49-
CREATE UNIQUE INDEX "configurations_key_key" ON "configurations"("key");
50-
5128
-- CreateIndex
5229
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
5330

express/prisma/schema.prisma

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,16 @@ datasource db {
1313
provider = "postgresql"
1414
}
1515

16-
model Configuration {
17-
id String @id @default(uuid())
18-
key String @unique // One response per review
19-
value String
20-
createdAt DateTime @default(now())
21-
updatedAt DateTime @updatedAt
22-
23-
@@map("configurations")
24-
}
25-
2616
// User model for both regular users and curators
2717
model User {
2818
id String @id @default(uuid())
2919
email String @unique
3020
password String
31-
firstName String
32-
lastName String
33-
avatar String?
34-
bio String?
35-
phone String?
36-
googleId String? @db.VarChar(255)
37-
facebookId String? @db.VarChar(255)
38-
emailVerifiedAt DateTime?
39-
emailVerificationCode String? @db.VarChar(64)
21+
name String
4022
createdAt DateTime @default(now())
4123
updatedAt DateTime @updatedAt
4224
43-
// Relations
4425
personalAccessTokens PersonalAccessToken[] @relation("TokenUser")
45-
locationId String?
4626
4727
@@index([email])
4828
@@map("users")

h3/prisma/migrations/20260308041653_init/migration.sql renamed to h3/prisma/migrations/20260311045759_init/migration.sql

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,11 @@
1-
-- CreateTable
2-
CREATE TABLE "configurations" (
3-
"id" TEXT NOT NULL,
4-
"key" TEXT NOT NULL,
5-
"value" TEXT NOT NULL,
6-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
7-
"updatedAt" TIMESTAMP(3) NOT NULL,
8-
9-
CONSTRAINT "configurations_pkey" PRIMARY KEY ("id")
10-
);
11-
121
-- CreateTable
132
CREATE TABLE "users" (
143
"id" TEXT NOT NULL,
154
"email" TEXT NOT NULL,
165
"password" TEXT NOT NULL,
17-
"firstName" TEXT NOT NULL,
18-
"lastName" TEXT NOT NULL,
19-
"avatar" TEXT,
20-
"bio" TEXT,
21-
"phone" TEXT,
22-
"googleId" VARCHAR(255),
23-
"facebookId" VARCHAR(255),
24-
"emailVerifiedAt" TIMESTAMP(3),
25-
"emailVerificationCode" VARCHAR(64),
6+
"name" TEXT NOT NULL,
267
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
278
"updatedAt" TIMESTAMP(3) NOT NULL,
28-
"locationId" TEXT,
299

3010
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
3111
);
@@ -45,9 +25,6 @@ CREATE TABLE "personal_access_tokens" (
4525
CONSTRAINT "personal_access_tokens_pkey" PRIMARY KEY ("id")
4626
);
4727

48-
-- CreateIndex
49-
CREATE UNIQUE INDEX "configurations_key_key" ON "configurations"("key");
50-
5128
-- CreateIndex
5229
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
5330

h3/prisma/schema.prisma

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,16 @@ datasource db {
1313
provider = "postgresql"
1414
}
1515

16-
model Configuration {
17-
id String @id @default(uuid())
18-
key String @unique // One response per review
19-
value String
20-
createdAt DateTime @default(now())
21-
updatedAt DateTime @updatedAt
22-
23-
@@map("configurations")
24-
}
25-
2616
// User model for both regular users and curators
2717
model User {
2818
id String @id @default(uuid())
2919
email String @unique
3020
password String
31-
firstName String
32-
lastName String
33-
avatar String?
34-
bio String?
35-
phone String?
36-
address String?
37-
googleId String? @db.VarChar(255)
38-
facebookId String? @db.VarChar(255)
39-
emailVerifiedAt DateTime?
40-
emailVerificationCode String? @db.VarChar(64)
21+
name String
4122
createdAt DateTime @default(now())
4223
updatedAt DateTime @updatedAt
4324
44-
// Relations
4525
personalAccessTokens PersonalAccessToken[] @relation("TokenUser")
46-
locationId String?
4726
4827
@@index([email])
4928
@@map("users")

prisma/migrations/20260309180617_init/migration.sql renamed to prisma/migrations/20260311045759_init/migration.sql

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
1-
-- CreateTable
2-
CREATE TABLE "configurations" (
3-
"id" TEXT NOT NULL,
4-
"key" TEXT NOT NULL,
5-
"value" TEXT NOT NULL,
6-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
7-
"updatedAt" TIMESTAMP(3) NOT NULL,
8-
9-
CONSTRAINT "configurations_pkey" PRIMARY KEY ("id")
10-
);
11-
121
-- CreateTable
132
CREATE TABLE "users" (
143
"id" TEXT NOT NULL,
154
"email" TEXT NOT NULL,
165
"password" TEXT NOT NULL,
17-
"firstName" TEXT NOT NULL,
18-
"lastName" TEXT NOT NULL,
19-
"avatar" TEXT,
20-
"bio" TEXT,
21-
"phone" TEXT,
22-
"address" TEXT,
23-
"googleId" VARCHAR(255),
24-
"facebookId" VARCHAR(255),
25-
"emailVerifiedAt" TIMESTAMP(3),
26-
"emailVerificationCode" VARCHAR(64),
6+
"name" TEXT NOT NULL,
277
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
288
"updatedAt" TIMESTAMP(3) NOT NULL,
29-
"locationId" TEXT,
309

3110
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
3211
);
@@ -46,9 +25,6 @@ CREATE TABLE "personal_access_tokens" (
4625
CONSTRAINT "personal_access_tokens_pkey" PRIMARY KEY ("id")
4726
);
4827

49-
-- CreateIndex
50-
CREATE UNIQUE INDEX "configurations_key_key" ON "configurations"("key");
51-
5228
-- CreateIndex
5329
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
5430

prisma/schema.prisma

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,16 @@ datasource db {
1313
provider = "postgresql"
1414
}
1515

16-
model Configuration {
16+
// User model for both regular users and curators
17+
model User {
1718
id String @id @default(uuid())
18-
key String @unique // One response per review
19-
value String
19+
email String @unique
20+
password String
21+
name String
2022
createdAt DateTime @default(now())
2123
updatedAt DateTime @updatedAt
2224
23-
@@map("configurations")
24-
}
25-
26-
// User model for both regular users and curators
27-
model User {
28-
id String @id @default(uuid())
29-
email String @unique
30-
password String
31-
firstName String
32-
lastName String
33-
avatar String?
34-
bio String?
35-
phone String?
36-
address String?
37-
googleId String? @db.VarChar(255)
38-
facebookId String? @db.VarChar(255)
39-
emailVerifiedAt DateTime?
40-
emailVerificationCode String? @db.VarChar(64)
41-
createdAt DateTime @default(now())
42-
updatedAt DateTime @updatedAt
43-
44-
// Relations
4525
personalAccessTokens PersonalAccessToken[] @relation("TokenUser")
46-
locationId String?
4726
4827
@@index([email])
4928
@@map("users")

tests/database/CreateDatabaseClient.test.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ let inc: number = new Date().getTime()
77

88
class User extends Model {
99
declare id: number
10-
declare firstName: string
11-
declare lastName: string
10+
declare name: string
1211
declare email: string
1312
}
1413

@@ -23,15 +22,13 @@ describer('Modeling Dats', () => {
2322
const user = await User.query().create({
2423
email: `john.doe${inc}@example.com`,
2524
password: 'password123',
26-
firstName: 'John',
27-
lastName: 'Doe',
25+
name: 'John Doe',
2826
})
2927

3028
expect(user).toBeDefined()
3129
expect(user.id).toBeDefined()
3230
expect(user.email).toBe(`john.doe${inc}@example.com`)
33-
expect(user.firstName).toBe('John')
34-
expect(user.lastName).toBe('Doe')
31+
expect(user.name).toBe('John Doe')
3532
})
3633

3734
it('can get a model', async () => {
@@ -40,8 +37,7 @@ describer('Modeling Dats', () => {
4037
expect(user).toBeDefined()
4138
expect(user?.id).toBeDefined()
4239
expect(user?.email).toBe(`john.doe${inc}@example.com`)
43-
expect(user?.firstName).toBe('John')
44-
expect(user?.lastName).toBe('Doe')
40+
expect(user?.name).toBe('John Doe')
4541
})
4642

4743
it('can update a model', async () => {
@@ -50,15 +46,13 @@ describer('Modeling Dats', () => {
5046
expect(user).toBeDefined()
5147

5248
if (user) {
53-
user.firstName = 'Jane'
54-
user.lastName = 'Doe'
49+
user.name = 'Jane Doe'
5550
await user.save()
5651

5752
const updatedUser = await User.query().where({ email: `john.doe${inc}@example.com` }).first()
5853

5954
expect(updatedUser).toBeDefined()
60-
expect(updatedUser?.firstName).toBe('Jane')
61-
expect(updatedUser?.lastName).toBe('Doe')
55+
expect(updatedUser?.name).toBe('Jane Doe')
6256
}
6357
})
6458

0 commit comments

Comments
 (0)