base con autenticacion, registro, modulo encuestas
This commit is contained in:
24
apps/api/src/database/seeds/states.seed.ts
Normal file
24
apps/api/src/database/seeds/states.seed.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
|
||||
import * as schema from '../index';
|
||||
import { states } from '../schema/general';
|
||||
|
||||
|
||||
export async function seedStates(db: NodePgDatabase<typeof schema>) {
|
||||
console.log('Seeding public state...');
|
||||
|
||||
// Insert roles
|
||||
const statesArray = ['estado1', 'estado2', 'estado3'];
|
||||
|
||||
for (const item of statesArray) {
|
||||
try {
|
||||
await db.insert(states).values({
|
||||
name: item
|
||||
}).onConflictDoNothing();
|
||||
// console.log(`State '${item}' created or already exists`);
|
||||
} catch (error) {
|
||||
console.error(`Error creating state '${item}':`, error);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('All states seeded successfully');
|
||||
}
|
||||
Reference in New Issue
Block a user