Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
健杭 徐
my-app
Commits
9407802d
Commit
9407802d
authored
Aug 31, 2025
by
健杭 徐
Browse files
add prisma
parent
953586b9
Changes
5
Show whitespace changes
Inline
Side-by-side
prisma/dev.db
0 → 100644
View file @
9407802d
File added
prisma/migrations/20250828151958_init/migration.sql
0 → 100644
View file @
9407802d
-- CreateTable
CREATE
TABLE
"User"
(
"id"
INTEGER
NOT
NULL
PRIMARY
KEY
AUTOINCREMENT
,
"userName"
TEXT
NOT
NULL
,
"password"
TEXT
NOT
NULL
);
-- CreateTable
CREATE
TABLE
"Room"
(
"id"
INTEGER
NOT
NULL
PRIMARY
KEY
AUTOINCREMENT
,
"name"
TEXT
NOT
NULL
,
"createdAt"
DATETIME
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
"updatedAt"
DATETIME
NOT
NULL
);
-- CreateTable
CREATE
TABLE
"Message"
(
"id"
INTEGER
NOT
NULL
PRIMARY
KEY
AUTOINCREMENT
,
"content"
TEXT
NOT
NULL
,
"senderId"
INTEGER
NOT
NULL
,
"roomId"
INTEGER
NOT
NULL
,
"createdAt"
DATETIME
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
CONSTRAINT
"Message_senderId_fkey"
FOREIGN
KEY
(
"senderId"
)
REFERENCES
"User"
(
"id"
)
ON
DELETE
RESTRICT
ON
UPDATE
CASCADE
,
CONSTRAINT
"Message_roomId_fkey"
FOREIGN
KEY
(
"roomId"
)
REFERENCES
"Room"
(
"id"
)
ON
DELETE
RESTRICT
ON
UPDATE
CASCADE
);
-- CreateIndex
CREATE
UNIQUE
INDEX
"User_userName_key"
ON
"User"
(
"userName"
);
prisma/migrations/20250829023846_add_cascade_delete_to_messages/migration.sql
0 → 100644
View file @
9407802d
-- RedefineTables
PRAGMA
defer_foreign_keys
=
ON
;
PRAGMA
foreign_keys
=
OFF
;
CREATE
TABLE
"new_Message"
(
"id"
INTEGER
NOT
NULL
PRIMARY
KEY
AUTOINCREMENT
,
"content"
TEXT
NOT
NULL
,
"senderId"
INTEGER
NOT
NULL
,
"roomId"
INTEGER
NOT
NULL
,
"createdAt"
DATETIME
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
CONSTRAINT
"Message_senderId_fkey"
FOREIGN
KEY
(
"senderId"
)
REFERENCES
"User"
(
"id"
)
ON
DELETE
RESTRICT
ON
UPDATE
CASCADE
,
CONSTRAINT
"Message_roomId_fkey"
FOREIGN
KEY
(
"roomId"
)
REFERENCES
"Room"
(
"id"
)
ON
DELETE
CASCADE
ON
UPDATE
CASCADE
);
INSERT
INTO
"new_Message"
(
"content"
,
"createdAt"
,
"id"
,
"roomId"
,
"senderId"
)
SELECT
"content"
,
"createdAt"
,
"id"
,
"roomId"
,
"senderId"
FROM
"Message"
;
DROP
TABLE
"Message"
;
ALTER
TABLE
"new_Message"
RENAME
TO
"Message"
;
PRAGMA
foreign_keys
=
ON
;
PRAGMA
defer_foreign_keys
=
OFF
;
prisma/migrations/migration_lock.toml
0 → 100644
View file @
9407802d
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider
=
"sqlite"
prisma/schema.prisma
0 → 100644
View file @
9407802d
//
This
is
your
Prisma
schema
file
,
//
learn
more
about
it
in
the
docs
:
https
://
pris
.
ly
/
d
/
prisma
-
schema
//
Looking
for
ways
to
speed
up
your
queries
,
or
scale
easily
with
your
serverless
or
edge
functions
?
//
Try
Prisma
Accelerate
:
https
://
pris
.
ly
/
cli
/
accelerate
-
init
generator
client
{
provider
=
"prisma-client-js"
output
=
"../generated/prisma"
binaryTargets
=
[
"native"
,
"debian-openssl-3.0.x"
]
}
datasource
db
{
provider
=
"sqlite"
url
=
env
(
"DATABASE_URL"
)
}
model
User
{
id
Int
@
id
@
default
(
autoincrement
())
userName
String
@
unique
password
String
messages
Message
[]
@
relation
(
"UserMessages"
)
}
model
Room
{
id
Int
@
id
@
default
(
autoincrement
())
name
String
messages
Message
[]
createdAt
DateTime
@
default
(
now
())
updatedAt
DateTime
@
updatedAt
}
model
Message
{
id
Int
@
id
@
default
(
autoincrement
())
content
String
senderId
Int
sender
User
@
relation
(
"UserMessages"
,
fields
:
[
senderId
],
references
:
[
id
])
roomId
Int
room
Room
@
relation
(
fields
:
[
roomId
],
references
:
[
id
],
onDelete
:
Cascade
)
createdAt
DateTime
@
default
(
now
())
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment