maxibase 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -63,7 +63,7 @@ Each build is tagged `{utc-timestamp}-{commit}` and the last 5 stay on the serve
63
63
  Roll back with `pnpm rollback` (the version before the live one), `pnpm rollback {tag}`, or
64
64
  list what is available with `pnpm rollback --list`. Rolling back does not undo migrations.
65
65
 
66
- Push your migration through SSH with `pnpm db:push-server`.
66
+ Push your migration through SSH with `pnpm db:push-prod`.
67
67
 
68
68
  In a project that uses the layer, these scripts run from the package, see [Scripts](#scripts).
69
69
 
@@ -204,8 +204,9 @@ The tables of the `auth` schema ship with the layer, in `layers/base/server/data
204
204
  Your `server/database/schema.ts` re-exports them and adds your own tables, so `pnpm update maxibase`
205
205
  brings their changes: run `pnpm db:generate` after an update. To customise one, copy it into your
206
206
  schema, a table declared in your file takes precedence over the package's one with the same name.
207
- Their relations come from `authRelations`, merged after yours in `db.ts`, so only define relations
208
- on your own tables.
207
+ Their relations come from `authRelations` in `layers/base/server/database/relations.ts`. To add a
208
+ relation to one of these tables, define the table in your `relations.ts`: your entry replaces the
209
+ layer's for that table, so repeat the layer's relations you still need there.
209
210
 
210
211
  `db.ts`, `relations.ts` and `access.ts` in `server/database` are optional, the layer has a default
211
212
  for each in `layers/base/server/database/defaults`: no relations of your own, and file access to
@@ -229,7 +230,7 @@ A project's `package.json` looks like this. Add any package your own files impor
229
230
  "db:seed": "npx jiti ./server/database/seed.ts",
230
231
  "db:generate": "drizzle-kit generate",
231
232
  "db:push": "drizzle-kit push",
232
- "db:push-server": "bash node_modules/maxibase/scripts/db/push-server.sh",
233
+ "db:push-prod": "bash node_modules/maxibase/scripts/db/push-server.sh",
233
234
  "db:restore": "bash node_modules/maxibase/scripts/db/restore.sh",
234
235
  "db:migrate": "npx jiti node_modules/maxibase/scripts/db/migrate.ts",
235
236
  "db:studio": "drizzle-kit studio",
@@ -5,8 +5,8 @@ services:
5
5
  env_file:
6
6
  - .env
7
7
  volumes:
8
- - ./volumes/files/public:/app/${NUXT_FILES_PUBLIC_FOLDER:-files}
9
- - ./volumes/files/private:/app/${NUXT_FILES_PRIVATE_FOLDER:-files}
8
+ - ./volumes/files/public:/app/${NUXT_FILES_PUBLIC_FOLDER:-files/public}
9
+ - ./volumes/files/private:/app/${NUXT_FILES_PRIVATE_FOLDER:-files/private}
10
10
  - ./volumes/backups:/app/backups
11
11
  ports:
12
12
  - ${SERVER_PORT:-3000}:3000
@@ -2,4 +2,12 @@ import { drizzle } from 'drizzle-orm/node-postgres'
2
2
  import { relations } from '#database/relations'
3
3
  import { authRelations } from '../relations'
4
4
 
5
- export const db = drizzle(useRuntimeConfig().db, { relations: { ...relations, ...authRelations } })
5
+ // defineRelations gives every table an entry, empty ones included: only the project's tables
6
+ // with relations override the layer's, so an empty entry never erases them
7
+ const own = Object.fromEntries(
8
+ Object.entries(relations).filter(([, table]) => Object.keys(table.relations).length),
9
+ )
10
+
11
+ export const db = drizzle(useRuntimeConfig().db, {
12
+ relations: { ...relations, ...authRelations, ...own } as typeof relations & typeof authRelations,
13
+ })
@@ -2,7 +2,7 @@ import * as schema from '#server/database/schema'
2
2
  import { defineRelationsPart } from 'drizzle-orm'
3
3
 
4
4
  // Built from the project schema, so they also apply to a table the project overrides.
5
- // Spread after the project's relations, so they replace any the project defines on these tables.
5
+ // A project entry for one of these tables replaces the layer's, see defaults/db.ts.
6
6
  export const authRelations = defineRelationsPart(schema, (r) => ({
7
7
  auth: {
8
8
  refreshTokens: r.many.refreshTokens({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maxibase",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Nuxt layer with auth, files, logs and backups",
5
5
  "keywords": [
6
6
  "nuxt",
@@ -44,7 +44,7 @@
44
44
  "db:seed": "npx jiti ./server/database/seed.ts",
45
45
  "db:generate": "drizzle-kit generate",
46
46
  "db:push": "drizzle-kit push",
47
- "db:push-server": "./scripts/db/push-server.sh",
47
+ "db:push-prod": "./scripts/db/push-server.sh",
48
48
  "db:restore": "./scripts/db/restore.sh",
49
49
  "db:migrate": "npx jiti ./scripts/db/migrate.ts",
50
50
  "db:studio": "drizzle-kit studio",