Fixing migrate and seed.

This commit is contained in:
Bradley Shellnut 2024-08-07 20:59:30 -07:00
parent 488b638d16
commit 049ab4ef0b
2 changed files with 11 additions and 9 deletions

View file

@ -2,8 +2,8 @@ import 'dotenv/config';
import postgres from 'postgres'; import postgres from 'postgres';
import { drizzle } from 'drizzle-orm/postgres-js'; import { drizzle } from 'drizzle-orm/postgres-js';
import { migrate } from 'drizzle-orm/postgres-js/migrator'; import { migrate } from 'drizzle-orm/postgres-js/migrator';
import env from '../env'; import env from '../../../../../env';
import config from '../../drizzle.config'; import config from '../../../../../../drizzle.config';
const connection = postgres({ const connection = postgres({
host: env.DATABASE_HOST || 'localhost', host: env.DATABASE_HOST || 'localhost',

View file

@ -1,5 +1,5 @@
import { Table, getTableName, sql } from 'drizzle-orm'; import { Table, getTableName, sql } from 'drizzle-orm';
import env from '../env'; import env from '../../../../../env';
import { db, pool } from '$db'; import { db, pool } from '$db';
import * as schema from './tables'; import * as schema from './tables';
import * as seeds from './seeds'; import * as seeds from './seeds';
@ -13,13 +13,15 @@ async function resetTable(db: db, table: Table) {
} }
for (const table of [ for (const table of [
schema.categories, schema.categoriesTable,
schema.categoriesToExternalIdsTable, schema.categoriesToExternalIdsTable,
schema.categories_to_games, schema.categories_to_games_table,
schema.collection_items, schema.collection_items,
schema.collections, schema.collections,
schema.credentialsTable,
schema.expansions, schema.expansions,
schema.externalIds, schema.externalIds,
schema.federatedIdentityTable,
schema.games, schema.games,
schema.gamesToExternalIds, schema.gamesToExternalIds,
schema.mechanics, schema.mechanics,
@ -29,14 +31,14 @@ for (const table of [
schema.publishers, schema.publishers,
schema.publishersToExternalIds, schema.publishersToExternalIds,
schema.publishers_to_games, schema.publishers_to_games,
schema.recoveryCodes, schema.recovery_codes,
schema.roles, schema.roles,
schema.sessionsTable, schema.sessionsTable,
schema.userRoles, schema.twoFactorTable,
schema.user_roles,
schema.usersTable, schema.usersTable,
schema.twoFactor,
schema.wishlists,
schema.wishlist_items, schema.wishlist_items,
schema.wishlists,
]) { ]) {
// await db.delete(table); // clear tables without truncating / resetting ids // await db.delete(table); // clear tables without truncating / resetting ids
await resetTable(db, table); await resetTable(db, table);