Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions dashboard/final-example/app/seed/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { invoices, customers, revenue, users } from '../lib/placeholder-data';

const sql = postgres(process.env.POSTGRES_URL!, { ssl: 'require' });

async function seedUsers() {
async function seedUsers(sql: postgres.TransactionSql) {
await sql`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`;
await sql`
CREATE TABLE IF NOT EXISTS users (
Expand All @@ -29,7 +29,7 @@ async function seedUsers() {
return insertedUsers;
}

async function seedInvoices() {
async function seedInvoices(sql: postgres.TransactionSql) {
await sql`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`;

await sql`
Expand All @@ -55,7 +55,7 @@ async function seedInvoices() {
return insertedInvoices;
}

async function seedCustomers() {
async function seedCustomers(sql: postgres.TransactionSql) {
await sql`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`;

await sql`
Expand All @@ -80,7 +80,7 @@ async function seedCustomers() {
return insertedCustomers;
}

async function seedRevenue() {
async function seedRevenue(sql: postgres.TransactionSql) {
await sql`
CREATE TABLE IF NOT EXISTS revenue (
month VARCHAR(4) NOT NULL UNIQUE,
Expand All @@ -104,10 +104,10 @@ async function seedRevenue() {
export async function GET() {
try {
const result = await sql.begin((sql) => [
seedUsers(),
seedCustomers(),
seedInvoices(),
seedRevenue(),
seedUsers(sql),
seedCustomers(sql),
seedInvoices(sql),
seedRevenue(sql),
]);

return Response.json({ message: 'Database seeded successfully' });
Expand Down
16 changes: 8 additions & 8 deletions dashboard/starter-example/app/seed/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { invoices, customers, revenue, users } from '../lib/placeholder-data';

const sql = postgres(process.env.POSTGRES_URL!, { ssl: 'require' });

async function seedUsers() {
async function seedUsers(sql: postgres.TransactionSql) {
await sql`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`;
await sql`
CREATE TABLE IF NOT EXISTS users (
Expand All @@ -29,7 +29,7 @@ async function seedUsers() {
return insertedUsers;
}

async function seedInvoices() {
async function seedInvoices(sql: postgres.TransactionSql) {
await sql`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`;

await sql`
Expand All @@ -55,7 +55,7 @@ async function seedInvoices() {
return insertedInvoices;
}

async function seedCustomers() {
async function seedCustomers(sql: postgres.TransactionSql) {
await sql`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`;

await sql`
Expand All @@ -80,7 +80,7 @@ async function seedCustomers() {
return insertedCustomers;
}

async function seedRevenue() {
async function seedRevenue(sql: postgres.TransactionSql) {
await sql`
CREATE TABLE IF NOT EXISTS revenue (
month VARCHAR(4) NOT NULL UNIQUE,
Expand All @@ -104,10 +104,10 @@ async function seedRevenue() {
export async function GET() {
try {
const result = await sql.begin((sql) => [
seedUsers(),
seedCustomers(),
seedInvoices(),
seedRevenue(),
seedUsers(sql),
seedCustomers(sql),
seedInvoices(sql),
seedRevenue(sql),
]);

return Response.json({ message: 'Database seeded successfully' });
Expand Down