mirror of
https://github.com/ZeroCatDev/ClassworksKV.git
synced 2025-07-01 20:09:23 +00:00
Update Dockerfile to handle database-specific commands and enhance Prisma schema for PostgreSQL and SQLite. Introduce new AccessType enum and KVStore model for improved data management. Clean up SQLite schema by removing unused fields.
This commit is contained in:
parent
0e490e5def
commit
420ba4277d
@ -10,13 +10,15 @@ ENV NODE_ENV=production \
|
||||
# Copy all application files
|
||||
COPY . .
|
||||
|
||||
# Copy specific database files based on DATABASE_TYPE and clean up
|
||||
RUN cp -r /prisma/database/${DATABASE_TYPE}/* /prisma/ && \
|
||||
rm -rf /prisma/database
|
||||
|
||||
# Install dependencies and generate Prisma client
|
||||
RUN npm install && \
|
||||
npx prisma migrate dev --name init && \
|
||||
npx prisma generate
|
||||
|
||||
USER node
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npm", "start"]
|
||||
# Run different commands based on DATABASE_TYPE
|
||||
CMD ["sh", "-c", "if [ \"$DATABASE_TYPE\" = \"sqlite\" ]; then (if [ ! -f /data/db.db ]; then npx prisma migrate dev --name init; else npx prisma migrate deploy; fi); else npx prisma migrate deploy; fi && npx prisma generate && npm run start"]
|
||||
|
@ -1,9 +1,36 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../generated/postgres/client"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum AccessType {
|
||||
PUBLIC // No password required for read/write
|
||||
PROTECTED // No password for read, password for write
|
||||
PRIVATE // Password required for read/write
|
||||
}
|
||||
|
||||
model KVStore {
|
||||
namespace String
|
||||
key String
|
||||
value Json
|
||||
creatorIp String? @default("")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@id([namespace, key])
|
||||
}
|
||||
|
||||
model Device {
|
||||
uuid String @id
|
||||
password String?
|
||||
passwordHint String?
|
||||
name String?
|
||||
accessType AccessType @default(PUBLIC)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
@ -33,5 +33,4 @@ model Device {
|
||||
accessType AccessType @default(PUBLIC)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
test String?
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user