@rebasepro/server-postgres 0.13.1-canary.g599dae0 → 0.13.1-canary.gcd6689e
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/dist/index.es.js +86 -16
- package/dist/index.es.js.map +1 -1
- package/dist/schema/generated-schema-staleness.d.ts +39 -0
- package/dist/src-DlPBctw_.js.map +1 -1
- package/package.json +6 -6
- package/src/cli.ts +79 -0
- package/src/collections/validate-relations.ts +107 -16
- package/src/schema/generated-schema-staleness.ts +164 -0
- package/src/schema/introspect-db-logic.ts +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CollectionConfig } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Notice a generated Drizzle schema that a *library upgrade* invalidated.
|
|
4
|
+
*
|
|
5
|
+
* `rebase dev` already watches `config/collections` and warns when a collection
|
|
6
|
+
* file changes. That covers drift the developer caused. It cannot cover this one,
|
|
7
|
+
* because nothing the developer owns changed: 0.13 derives `category_id` where
|
|
8
|
+
* 0.12 derived `categorie_id`, from the same unedited collection. The watcher
|
|
9
|
+
* never fires, and `backend/src/schema.generated.ts` quietly stops describing the
|
|
10
|
+
* schema the runtime expects.
|
|
11
|
+
*
|
|
12
|
+
* The consequence is not cosmetic. Boot-ensure renames the column in the
|
|
13
|
+
* database, then relation validation reads the stale module and refuses to
|
|
14
|
+
* start — on that boot and every boot after it, because the rename is already
|
|
15
|
+
* applied and will not be attempted again.
|
|
16
|
+
*
|
|
17
|
+
* Deliberately narrow: this answers "does the generated schema name a foreign key
|
|
18
|
+
* the way the previous rule did", not "is this file what we would generate now".
|
|
19
|
+
* The wide question would report every whitespace change in the generator as a
|
|
20
|
+
* fatal staleness, and a check that cries wolf gets switched off.
|
|
21
|
+
*/
|
|
22
|
+
/** One column the generated schema names under the pre-0.13 rule. */
|
|
23
|
+
export interface LegacyForeignKeyName {
|
|
24
|
+
/** Table whose column declaration is stale. */
|
|
25
|
+
table: string;
|
|
26
|
+
/** The name the generated schema declares. */
|
|
27
|
+
legacy: string;
|
|
28
|
+
/** The name this release derives, and which the database now carries. */
|
|
29
|
+
current: string;
|
|
30
|
+
/** `<collection>.<relation>` that derives it, for the message. */
|
|
31
|
+
relation: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @param generatedSource contents of `backend/src/schema.generated.ts`
|
|
35
|
+
* @param collections the project's collections, as this release reads them
|
|
36
|
+
*/
|
|
37
|
+
export declare function findLegacyForeignKeyNames(generatedSource: string, collections: CollectionConfig[]): LegacyForeignKeyName[];
|
|
38
|
+
/** One-line summary for a log or a CLI notice. */
|
|
39
|
+
export declare function describeLegacyForeignKeyNames(found: LegacyForeignKeyName[]): string;
|