Refactor to use ai/rsc (#253)

This commit is contained in:
Jeremy 2024-03-14 20:00:52 +03:00 committed by GitHub
parent 69ca8fcc22
commit e85ba803dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 2799 additions and 740 deletions

34
scripts/seed.mjs Normal file
View 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)
})