Skip to content

Commit

Permalink
chore: remove deprecated collection field
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Mar 26, 2024
1 parent 21cf336 commit 91b93c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
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

0 comments on commit 91b93c4

Please sign in to comment.