Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(db): Rename all collection usage to tables #10460

Merged
merged 12 commits into from
Mar 27, 2024
Prev Previous commit
Next Next commit
chore: remove deprecated collection field
  • Loading branch information
bholmesdev committed Mar 26, 2024
commit 91b93c4caf1937156daa836f252064443de87bfc
3 changes: 0 additions & 3 deletions packages/db/src/core/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ const baseColumnSchema = z.object({

// Defined when `defineReadableTable()` is called
name: z.string().optional(),
/** @deprecated renamed to table */
collection: z.string().optional(),
table: z.string().optional(),
});

Expand Down Expand Up @@ -196,7 +194,6 @@ export const tablesSchema = z.preprocess((rawTables) => {
const { columns } = z.object({ columns: z.record(z.any()) }).parse(table, { errorMap });
for (const [columnName, column] of Object.entries(columns)) {
column.schema.name = columnName;
column.schema.collection = tableName;
column.schema.table = tableName;
}
}
Expand Down
5 changes: 2 additions & 3 deletions packages/db/src/runtime/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function getCreateForeignKeyQueries(tableName: string, table: DBTable) {
if (!firstReference) {
throw new Error(FOREIGN_KEY_REFERENCES_EMPTY_ERROR(tableName));
}
const referencedTable = firstReference.schema.table ?? firstReference.schema.collection;
const referencedTable = firstReference.schema.table;
if (!referencedTable) {
throw new Error(FOREIGN_KEY_DNE_ERROR(tableName));
}
Expand Down Expand Up @@ -125,8 +125,7 @@ export function getModifiers(columnName: string, column: DBColumn) {
}
const references = getReferencesConfig(column);
if (references) {
const { table, collection, name } = references.schema;
const tableName = table ?? collection;
const { table: tableName, name } = references.schema;
if (!tableName || !name) {
throw new Error(REFERENCE_DNE_ERROR(columnName));
}
Expand Down
Loading