Refactor to use ai/rsc (#253)
This commit is contained in:
parent
69ca8fcc22
commit
e85ba803dd
66 changed files with 2799 additions and 740 deletions
34
scripts/seed.mjs
Normal file
34
scripts/seed.mjs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { db } from '@vercel/postgres'
|
||||
|
||||
async function seedUsers(client) {
|
||||
try {
|
||||
await client.sql`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`
|
||||
const createTable = await client.sql`
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||
email TEXT NOT NULL UNIQUE,
|
||||
password TEXT NOT NULL
|
||||
salt TEXT NOT NULL
|
||||
);
|
||||
`
|
||||
|
||||
console.log(`Created "users" table`)
|
||||
|
||||
return {
|
||||
createTable,
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error seeding users:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const client = await db.connect()
|
||||
await seedUsers(client)
|
||||
await client.end()
|
||||
}
|
||||
|
||||
main().catch(err => {
|
||||
console.error('An error occurred while attempting to seed the database:', err)
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue