@meith/db 0.21.0 → 0.21.2
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/package.json +30 -30
- package/src/index.ts +1 -0
- package/src/schema-state.ts +22 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meith/db",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,35 +22,35 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"drizzle-orm": "^0.45.2",
|
|
24
24
|
"postgres": "^3.4.7",
|
|
25
|
-
"@meith/accounts": "0.21.
|
|
26
|
-
"@meith/
|
|
27
|
-
"@meith/
|
|
28
|
-
"@meith/
|
|
29
|
-
"@meith/
|
|
30
|
-
"@meith/
|
|
31
|
-
"@meith/avatars": "0.21.
|
|
32
|
-
"@meith/drafts": "0.21.
|
|
33
|
-
"@meith/
|
|
34
|
-
"@meith/
|
|
35
|
-
"@meith/
|
|
36
|
-
"@meith/
|
|
37
|
-
"@meith/
|
|
38
|
-
"@meith/marketplace": "0.21.
|
|
39
|
-
"@meith/moderation": "0.21.
|
|
40
|
-
"@meith/
|
|
41
|
-
"@meith/notifications": "0.21.
|
|
42
|
-
"@meith/
|
|
43
|
-
"@meith/
|
|
44
|
-
"@meith/
|
|
45
|
-
"@meith/
|
|
46
|
-
"@meith/
|
|
47
|
-
"@meith/reputation": "0.21.
|
|
48
|
-
"@meith/
|
|
49
|
-
"@meith/
|
|
50
|
-
"@meith/
|
|
51
|
-
"@meith/
|
|
52
|
-
"@meith/
|
|
53
|
-
"@meith/
|
|
25
|
+
"@meith/accounts": "0.21.2",
|
|
26
|
+
"@meith/antispam": "0.21.2",
|
|
27
|
+
"@meith/attachments": "0.21.2",
|
|
28
|
+
"@meith/admin": "0.21.2",
|
|
29
|
+
"@meith/authorization": "0.21.2",
|
|
30
|
+
"@meith/api": "0.21.2",
|
|
31
|
+
"@meith/avatars": "0.21.2",
|
|
32
|
+
"@meith/drafts": "0.21.2",
|
|
33
|
+
"@meith/core": "0.21.2",
|
|
34
|
+
"@meith/events": "0.21.2",
|
|
35
|
+
"@meith/forums": "0.21.2",
|
|
36
|
+
"@meith/groups": "0.21.2",
|
|
37
|
+
"@meith/messages": "0.21.2",
|
|
38
|
+
"@meith/marketplace": "0.21.2",
|
|
39
|
+
"@meith/moderation": "0.21.2",
|
|
40
|
+
"@meith/markdown": "0.21.2",
|
|
41
|
+
"@meith/notifications": "0.21.2",
|
|
42
|
+
"@meith/polls": "0.21.2",
|
|
43
|
+
"@meith/plugin-kit": "0.21.2",
|
|
44
|
+
"@meith/profile-fields": "0.21.2",
|
|
45
|
+
"@meith/i18n": "0.21.2",
|
|
46
|
+
"@meith/relations": "0.21.2",
|
|
47
|
+
"@meith/reputation": "0.21.2",
|
|
48
|
+
"@meith/search": "0.21.2",
|
|
49
|
+
"@meith/settings": "0.21.2",
|
|
50
|
+
"@meith/signatures": "0.21.2",
|
|
51
|
+
"@meith/threads": "0.21.2",
|
|
52
|
+
"@meith/tasks": "0.21.2",
|
|
53
|
+
"@meith/subscriptions": "0.21.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"drizzle-kit": "^0.31.6",
|
package/src/index.ts
CHANGED
|
@@ -221,6 +221,7 @@ export { PostgresReportRepository } from './report-repo'
|
|
|
221
221
|
export { PostgresReputationRepository } from './reputation-repo'
|
|
222
222
|
export { resultRows } from './result-rows'
|
|
223
223
|
export * from './schema'
|
|
224
|
+
export { expectedTables, missingTables } from './schema-state'
|
|
224
225
|
export {
|
|
225
226
|
indexedSubjectSql,
|
|
226
227
|
PostgresSearchRepository,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getTableName, is, sql } from 'drizzle-orm'
|
|
2
|
+
import { PgTable } from 'drizzle-orm/pg-core'
|
|
3
|
+
|
|
4
|
+
import type { Database } from './client'
|
|
5
|
+
import { resultRows } from './result-rows'
|
|
6
|
+
import * as schema from './schema'
|
|
7
|
+
|
|
8
|
+
export function expectedTables(): readonly string[] {
|
|
9
|
+
return Object.values(schema as Record<string, unknown>)
|
|
10
|
+
.filter((value) => is(value, PgTable))
|
|
11
|
+
.map((table) => getTableName(table as PgTable))
|
|
12
|
+
.sort()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function missingTables(db: Database): Promise<readonly string[]> {
|
|
16
|
+
const result = await db.execute(sql`
|
|
17
|
+
select table_name from information_schema.tables where table_schema = 'public'
|
|
18
|
+
`)
|
|
19
|
+
|
|
20
|
+
const present = new Set(resultRows<{ table_name: string }>(result).map((row) => row.table_name))
|
|
21
|
+
return expectedTables().filter((table) => !present.has(table))
|
|
22
|
+
}
|