vercel / next-learn

Learn Next.js Starter Code
https://next-learn-dashboard.vercel.sh/
MIT License
3.42k stars 1.8k forks source link

Cannot run seed.js #586

Open royli1118 opened 5 months ago

royli1118 commented 5 months ago

After I run npm run seed, here is the error message,

seed node -r dotenv/config ./scripts/seed.js

node:events:492 throw er; // Unhandled 'error' event ^

Error: getaddrinfo ENOTFOUND ep-plain-union-a7292e8g-pooler.ap-southeast-2.postgres.vercel-storage.com at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) Emitted 'error' event on WebSocket instance at: at emitErrorAndClose (/Users/roy/Documents/Code/nextjs-dashboard/node_modules/ws/lib/websocket.js:1016:13) at ClientRequest. (/Users/roy/Documents/Code/nextjs-dashboard/node_modules/ws/lib/websocket.js:864:5) at ClientRequest.emit (node:events:514:28) at TLSSocket.socketErrorListener (node:_http_client:495:9) at TLSSocket.emit (node:events:514:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'ep-plain-union-a7292e8g-pooler.ap-southeast-2.postgres.vercel-storage.com' }

Node.js v20.10.0

Could anyone help?

NathanHTC commented 4 months ago

The error message you're encountering, Error: getaddrinfo ENOTFOUND, typically indicates a problem with DNS resolution, meaning the Node.js application is unable to resolve the hostname of your PostgreSQL database to an IP address. The hostname in question here appears to be related to a database service, possibly provided by Vercel, and the error suggests that the Node.js process can't find or connect to the specified database server.

Here are several steps you can take to troubleshoot and hopefully resolve this issue:

  1. Verify Database Hostname Double-check that the hostname ep-plain-union-a7292e8g-pooler.ap-southeast-2.postgres.vercel-storage.com is correct. It's possible there could be a typo in your .env file or wherever your database configuration is specified.
  2. Check .env File and Environment Variables Ensure your .env file (or other configuration files) is correctly set up and located in the right directory from where you're running the npm run seed command. The dotenv library loads environment variables from this file. Verify that the environment variable for your database URL (often something like DATABASE_URL) matches the expected format and uses the correct hostname.
  3. Test DNS Resolution Try to resolve the DNS name manually using tools like ping or nslookup from your terminal or command prompt to ensure that the hostname can be resolved to an IP address from your network.

bash Copy code nslookup ep-plain-union-a7292e8g-pooler.ap-southeast-2.postgres.vercel-storage.com If the DNS resolution fails, there might be a network issue, or the hostname might not be correctly configured in the DNS.

  1. Internet Connection and VPN/Proxy Settings Ensure that your internet connection is stable and that you're not behind a VPN or proxy that might interfere with DNS resolution or block connections to the database server.
  2. Firewall and Security Group Settings If you're running this in an environment with a firewall or cloud security groups (e.g., AWS, Google Cloud, Azure), make sure that outgoing connections to the PostgreSQL server on the required port (usually 5432) are allowed.
  3. Contact Database Host or Support If you've confirmed the hostname is correct and you're still facing issues, there might be a problem with the database service itself. Contact Vercel support or the support team for your database hosting service for further assistance. There could be an issue on their end or additional configuration required for your account.
  4. Review Database Client Configuration Make sure your database client configuration in the seed.js script (or related database connection logic) correctly uses the environment variables loaded by dotenv. Incorrect configuration could lead to this error if the hostname isn't being correctly passed to the database client. Addressing these points should help identify and resolve the ENOTFOUND error, allowing your seeding script to connect to the PostgreSQL database successfully.
jnovak-SM2Dev commented 4 months ago

For anyone that gets stuck, try changing .env.local to .env. This fixed the issue for me.

prats24 commented 3 months ago

node:events:496 throw er; // Unhandled 'error' event ^

AggregateError at internalConnectMultiple (node:net:1114:18) at internalConnectMultiple (node:net:1177:5) at Timeout.internalConnectMultipleTimeout (node:net:1687:3) at listOnTimeout (node:internal/timers:575:11) at process.processTimers (node:internal/timers:514:7) Emitted 'error' event on WebSocket instance at: at emitErrorAndClose (/Users/prateek/Desktop/nextjs/nextjs-dashboard/node_modules/ws/lib/websocket.js:1016:13) at ClientRequest. (/Users/prateek/Desktop/nextjs/nextjs-dashboard/node_modules/ws/lib/websocket.js:864:5) at ClientRequest.emit (node:events:518:28) at TLSSocket.socketErrorListener (node:_http_client:495:9) at TLSSocket.emit (node:events:518:28) at emitErrorNT (node:internal/streams/destroy:169:8) at emitErrorCloseNT (node:internal/streams/destroy:128:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { code: 'ETIMEDOUT',

Error: connect ETIMEDOUT 44.199.59.172:443
    at createConnectionError (node:net:1634:14)
    at Timeout.internalConnectMultipleTimeout (node:net:1685:38)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -60,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '44.199.59.172',
  port: 443
},
Error: connect EHOSTUNREACH 2600:1f18:240c:544d:621b:957c:81:5e5b:443 - Local (:::52593)
    at internalConnectMultiple (node:net:1176:40)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -65,
  code: 'EHOSTUNREACH',
  syscall: 'connect',
  address: '2600:1f18:240c:544d:621b:957c:81:5e5b',
  port: 443
},
Error: connect ETIMEDOUT 100.26.116.133:443
    at createConnectionError (node:net:1634:14)
    at Timeout.internalConnectMultipleTimeout (node:net:1685:38)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -60,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '100.26.116.133',
  port: 443
},
Error: connect EHOSTUNREACH 2600:1f18:240c:5419:4ecf:2a7c:cf52:31ae:443 - Local (:::52595)
    at internalConnectMultiple (node:net:1176:40)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -65,
  code: 'EHOSTUNREACH',
  syscall: 'connect',
  address: '2600:1f18:240c:5419:4ecf:2a7c:cf52:31ae',
  port: 443
},
Error: connect ETIMEDOUT 52.20.107.131:443
    at createConnectionError (node:net:1634:14)
    at Timeout.internalConnectMultipleTimeout (node:net:1685:38)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -60,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '52.20.107.131',
  port: 443
},
Error: connect EHOSTUNREACH 2600:1f18:240c:543b:a8aa:14fb:d008:11fe:443 - Local (:::52597)
    at internalConnectMultiple (node:net:1176:40)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -65,
  code: 'EHOSTUNREACH',
  syscall: 'connect',
  address: '2600:1f18:240c:543b:a8aa:14fb:d008:11fe',
  port: 443
},
Error: connect ETIMEDOUT 44.207.148.149:443
    at createConnectionError (node:net:1634:14)
    at Timeout.internalConnectMultipleTimeout (node:net:1685:38)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -60,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '44.207.148.149',
  port: 443
},
Error: connect EHOSTUNREACH 2600:1f18:240c:5421:acd1:6284:5a8a:d6e9:443 - Local (:::52599)
    at internalConnectMultiple (node:net:1176:40)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -65,
  code: 'EHOSTUNREACH',
  syscall: 'connect',
  address: '2600:1f18:240c:5421:acd1:6284:5a8a:d6e9',
  port: 443
},
Error: connect ETIMEDOUT 34.194.100.28:443
    at createConnectionError (node:net:1634:14)
    at Timeout.internalConnectMultipleTimeout (node:net:1685:38)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -60,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '34.194.100.28',
  port: 443
},
Error: connect EHOSTUNREACH 2600:1f18:240c:540b:c14a:4d57:1251:234d:443 - Local (:::52601)
    at internalConnectMultiple (node:net:1176:40)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -65,
  code: 'EHOSTUNREACH',
  syscall: 'connect',
  address: '2600:1f18:240c:540b:c14a:4d57:1251:234d',
  port: 443
},
Error: connect ETIMEDOUT 23.23.229.9:443
    at createConnectionError (node:net:1634:14)
    at Timeout.internalConnectMultipleTimeout (node:net:1685:38)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -60,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '23.23.229.9',
  port: 443
},
Error: connect EHOSTUNREACH 2600:1f18:240c:5454:82a4:8209:20f8:a5c1:443 - Local (:::52603)
    at internalConnectMultiple (node:net:1176:40)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -65,
  code: 'EHOSTUNREACH',
  syscall: 'connect',
  address: '2600:1f18:240c:5454:82a4:8209:20f8:a5c1',
  port: 443
}

] }

Node.js v20.11.1

Not able to resolve this error.

argon-3467 commented 3 months ago

I encountered the same issue did you find any solution?

Edit: I created another database but with a different region this time and it worked.

vignxs commented 3 months ago

try running vercel dev instead of npm run dev

that did the magic for me https://github.com/orgs/vercel/discussions/2350#discussioncomment-5850746

sabaoonnayyarai commented 3 months ago

Cannot resolve this env filename is ".env" nslookup us-east-1.aws.neon.tech returned: Name and Address, they were 12 in vercel, the status is available region is Washington, D.C., USA

npm run seed

seed node -r dotenv/config ./scripts/seed.js

node:events:497 throw er; // Unhandled 'error' event ^

AggregateError [ETIMEDOUT]: at internalConnectMultiple (node:net:1116:18) at internalConnectMultiple (node:net:1184:5) at Timeout.internalConnectMultipleTimeout (node:net:1707:5) at listOnTimeout (node:internal/timers:575:11) at process.processTimers (node:internal/timers:514:7) Emitted 'error' event on WebSocket instance at: at emitErrorAndClose (/home/sab/Public/bell/NextJs/nextjs-dashboard/node_modules/ws/lib/websocket.js:1016:13) at ClientRequest. (/home/sab/Public/bell/NextJs/nextjs-dashboard/node_modules/ws/lib/websocket.js:864:5) at ClientRequest.emit (node:events:519:28) at TLSSocket.socketErrorListener (node:_http_client:492:9) at TLSSocket.emit (node:events:519:28) at emitErrorNT (node:internal/streams/destroy:169:8) at emitErrorCloseNT (node:internal/streams/destroy:128:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { code: 'ETIMEDOUT',

Error: connect ETIMEDOUT 34.194.100.28:443
    at createConnectionError (node:net:1643:14)
    at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '34.194.100.28',
  port: 443
},
Error: connect ENETUNREACH 2600:1f18:240c:5454:82a4:8209:20f8:a5c1:443 - Local (:::0)
    at internalConnectMultiple (node:net:1180:16)
    at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -101,
  code: 'ENETUNREACH',
  syscall: 'connect',
  address: '2600:1f18:240c:5454:82a4:8209:20f8:a5c1',
  port: 443
},
Error: connect ETIMEDOUT 52.20.107.131:443
    at createConnectionError (node:net:1643:14)
    at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '52.20.107.131',
  port: 443
},
Error: connect ENETUNREACH 2600:1f18:240c:5421:acd1:6284:5a8a:d6e9:443 - Local (:::0)
    at internalConnectMultiple (node:net:1180:16)
    at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -101,
  code: 'ENETUNREACH',
  syscall: 'connect',
  address: '2600:1f18:240c:5421:acd1:6284:5a8a:d6e9',
  port: 443
},
Error: connect ETIMEDOUT 100.26.116.133:443
    at createConnectionError (node:net:1643:14)
    at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '100.26.116.133',
  port: 443
},
Error: connect ENETUNREACH 2600:1f18:240c:543b:a8aa:14fb:d008:11fe:443 - Local (:::0)
    at internalConnectMultiple (node:net:1180:16)
    at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -101,
  code: 'ENETUNREACH',
  syscall: 'connect',
  address: '2600:1f18:240c:543b:a8aa:14fb:d008:11fe',
  port: 443
},
Error: connect ETIMEDOUT 23.23.229.9:443
    at createConnectionError (node:net:1643:14)
    at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '23.23.229.9',
  port: 443
},
Error: connect ENETUNREACH 2600:1f18:240c:540b:c14a:4d57:1251:234d:443 - Local (:::0)
    at internalConnectMultiple (node:net:1180:16)
    at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -101,
  code: 'ENETUNREACH',
  syscall: 'connect',
  address: '2600:1f18:240c:540b:c14a:4d57:1251:234d',
  port: 443
},
Error: connect ETIMEDOUT 44.199.59.172:443
    at createConnectionError (node:net:1643:14)
    at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '44.199.59.172',
  port: 443
},
Error: connect ENETUNREACH 2600:1f18:240c:5419:4ecf:2a7c:cf52:31ae:443 - Local (:::0)
    at internalConnectMultiple (node:net:1180:16)
    at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -101,
  code: 'ENETUNREACH',
  syscall: 'connect',
  address: '2600:1f18:240c:5419:4ecf:2a7c:cf52:31ae',
  port: 443
},
Error: connect ETIMEDOUT 44.207.148.149:443
    at createConnectionError (node:net:1643:14)
    at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '44.207.148.149',
  port: 443
},
Error: connect ENETUNREACH 2600:1f18:240c:544d:621b:957c:81:5e5b:443 - Local (:::0)
    at internalConnectMultiple (node:net:1180:16)
    at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  errno: -101,
  code: 'ENETUNREACH',
  syscall: 'connect',
  address: '2600:1f18:240c:544d:621b:957c:81:5e5b',
  port: 443
}

] }

Node.js v21.6.2

vignxs commented 3 months ago

`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE TABLE IF NOT EXISTS users ( id UUID DEFAULT uuid_generate_v4() PRIMARY KEY, name VARCHAR(255) NOT NULL, email TEXT NOT NULL UNIQUE, password TEXT NOT NULL );

CREATE TABLE IF NOT EXISTS invoices ( id UUID DEFAULT uuid_generate_v4() PRIMARY KEY, customer_id UUID NOT NULL, amount INT NOT NULL, status VARCHAR(255) NOT NULL, date DATE NOT NULL );

CREATE TABLE IF NOT EXISTS customers ( id UUID DEFAULT uuid_generate_v4() PRIMARY KEY, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, image_url VARCHAR(255) NOT NULL );

CREATE TABLE IF NOT EXISTS revenue ( month VARCHAR(4) NOT NULL UNIQUE, revenue INT NOT NULL );

INSERT INTO customers (id, name, email, image_url) VALUES ('3958dc9e-712f-4377-85e9-fec4b6a6442a', 'Delba de Oliveira', 'delba@oliveira.com', '/customers/delba-de-oliveira.png'), ('3958dc9e-742f-4377-85e9-fec4b6a6442a', 'Lee Robinson', 'lee@robinson.com', '/customers/lee-robinson.png'), ('3958dc9e-737f-4377-85e9-fec4b6a6442a', 'Hector Simpson', 'hector@simpson.com', '/customers/hector-simpson.png'), ('50ca3e18-62cd-11ee-8c99-0242ac120002', 'Steven Tey', 'steven@tey.com', '/customers/steven-tey.png'), ('3958dc9e-787f-4377-85e9-fec4b6a6442a', 'Steph Dietz', 'steph@dietz.com', '/customers/steph-dietz.png'), ('76d65c26-f784-44a2-ac19-586678f7c2f2', 'Michael Novotny', 'michael@novotny.com', '/customers/michael-novotny.png'), ('d6e15727-9fe1-4961-8c5b-ea44a9bd81aa', 'Evil Rabbit', 'evil@rabbit.com', '/customers/evil-rabbit.png'), ('126eed9c-c90c-4ef6-a4a8-fcf7408d3c66', 'Emil Kowalski', 'emil@kowalski.com', '/customers/emil-kowalski.png'), ('CC27C14A-0ACF-4F4A-A6C9-D45682C144B9', 'Amy Burns', 'amy@burns.com', '/customers/amy-burns.png'), ('13D07535-C59E-4157-A011-F8D2EF4E0CBB', 'Balazs Orban', 'balazs@orban.com', '/customers/balazs-orban.png') ON CONFLICT (id) DO NOTHING;

INSERT INTO invoices (customer_id, amount, status, date) VALUES ('3958dc9e-712f-4377-85e9-fec4b6a6442a', 15795, 'pending', '2022-12-06'), ('3958dc9e-742f-4377-85e9-fec4b6a6442a', 20348, 'pending', '2022-11-14'), ('3958dc9e-787f-4377-85e9-fec4b6a6442a', 3040, 'paid', '2022-10-29'), ('50ca3e18-62cd-11ee-8c99-0242ac120002', 44800, 'paid', '2023-09-10'), ('3958dc9e-787f-4377-85e9-fec4b6a6442a', 34577, 'pending', '2023-08-05'), ('76d65c26-f784-44a2-ac19-586678f7c2f2', 54246, 'pending', '2023-07-16'), ('d6e15727-9fe1-4961-8c5b-ea44a9bd81aa', 666, 'pending', '2023-06-27'), ('50ca3e18-62cd-11ee-8c99-0242ac120002', 32545, 'paid', '2023-06-09'), ('3958dc9e-787f-4377-85e9-fec4b6a6442a', 1250, 'paid', '2023-06-17'), ('76d65c26-f784-44a2-ac19-586678f7c2f2', 8546, 'paid', '2023-06-07'), ('3958dc9e-742f-4377-85e9-fec4b6a6442a', 500, 'paid', '2023-08-19'), ('76d65c26-f784-44a2-ac19-586678f7c2f2', 8945, 'paid', '2023-06-03'), ('3958dc9e-737f-4377-85e9-fec4b6a6442a', 8945, 'paid', '2023-06-18'), ('3958dc9e-712f-4377-85e9-fec4b6a6442a', 8945, 'paid', '2023-10-04'), ('3958dc9e-737f-4377-85e9-fec4b6a6442a', 1000, 'paid', '2022-06-05') ON CONFLICT (id) DO NOTHING;

INSERT INTO revenue (month, revenue) VALUES ('Jan', 2000), ('Feb', 1800), ('Mar', 2200), ('Apr', 2500), ('May', 2300), ('Jun', 3200), ('Jul', 3500), ('Aug', 3700), ('Sep', 2500), ('Oct', 2800), ('Nov', 3000), ('Dec', 4800) ON CONFLICT (month) DO NOTHING;

INSERT INTO users (id, name, email, password) VALUES ('410544b2-4001-4271-9855-fec4b6a6442a', 'User', 'user@nextmail.com', '123456'); `

vignxs commented 3 months ago

run this one by one in vercel ui then in local use vercel dev to run the app for now forget about the seed part it's not worth debugging

sabaoonnayyarai commented 3 months ago

`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE TABLE IF NOT EXISTS users ( id UUID DEFAULT uuid_generate_v4() PRIMARY KEY, name VARCHAR(255) NOT NULL, email TEXT NOT NULL UNIQUE, password TEXT NOT NULL );

CREATE TABLE IF NOT EXISTS invoices ( id UUID DEFAULT uuid_generate_v4() PRIMARY KEY, customer_id UUID NOT NULL, amount INT NOT NULL, status VARCHAR(255) NOT NULL, date DATE NOT NULL );

CREATE TABLE IF NOT EXISTS customers ( id UUID DEFAULT uuid_generate_v4() PRIMARY KEY, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, image_url VARCHAR(255) NOT NULL );

CREATE TABLE IF NOT EXISTS revenue ( month VARCHAR(4) NOT NULL UNIQUE, revenue INT NOT NULL );

INSERT INTO customers (id, name, email, image_url) VALUES ('3958dc9e-712f-4377-85e9-fec4b6a6442a', 'Delba de Oliveira', 'delba@oliveira.com', '/customers/delba-de-oliveira.png'), ('3958dc9e-742f-4377-85e9-fec4b6a6442a', 'Lee Robinson', 'lee@robinson.com', '/customers/lee-robinson.png'), ('3958dc9e-737f-4377-85e9-fec4b6a6442a', 'Hector Simpson', 'hector@simpson.com', '/customers/hector-simpson.png'), ('50ca3e18-62cd-11ee-8c99-0242ac120002', 'Steven Tey', 'steven@tey.com', '/customers/steven-tey.png'), ('3958dc9e-787f-4377-85e9-fec4b6a6442a', 'Steph Dietz', 'steph@dietz.com', '/customers/steph-dietz.png'), ('76d65c26-f784-44a2-ac19-586678f7c2f2', 'Michael Novotny', 'michael@novotny.com', '/customers/michael-novotny.png'), ('d6e15727-9fe1-4961-8c5b-ea44a9bd81aa', 'Evil Rabbit', 'evil@rabbit.com', '/customers/evil-rabbit.png'), ('126eed9c-c90c-4ef6-a4a8-fcf7408d3c66', 'Emil Kowalski', 'emil@kowalski.com', '/customers/emil-kowalski.png'), ('CC27C14A-0ACF-4F4A-A6C9-D45682C144B9', 'Amy Burns', 'amy@burns.com', '/customers/amy-burns.png'), ('13D07535-C59E-4157-A011-F8D2EF4E0CBB', 'Balazs Orban', 'balazs@orban.com', '/customers/balazs-orban.png') ON CONFLICT (id) DO NOTHING;

INSERT INTO invoices (customer_id, amount, status, date) VALUES ('3958dc9e-712f-4377-85e9-fec4b6a6442a', 15795, 'pending', '2022-12-06'), ('3958dc9e-742f-4377-85e9-fec4b6a6442a', 20348, 'pending', '2022-11-14'), ('3958dc9e-787f-4377-85e9-fec4b6a6442a', 3040, 'paid', '2022-10-29'), ('50ca3e18-62cd-11ee-8c99-0242ac120002', 44800, 'paid', '2023-09-10'), ('3958dc9e-787f-4377-85e9-fec4b6a6442a', 34577, 'pending', '2023-08-05'), ('76d65c26-f784-44a2-ac19-586678f7c2f2', 54246, 'pending', '2023-07-16'), ('d6e15727-9fe1-4961-8c5b-ea44a9bd81aa', 666, 'pending', '2023-06-27'), ('50ca3e18-62cd-11ee-8c99-0242ac120002', 32545, 'paid', '2023-06-09'), ('3958dc9e-787f-4377-85e9-fec4b6a6442a', 1250, 'paid', '2023-06-17'), ('76d65c26-f784-44a2-ac19-586678f7c2f2', 8546, 'paid', '2023-06-07'), ('3958dc9e-742f-4377-85e9-fec4b6a6442a', 500, 'paid', '2023-08-19'), ('76d65c26-f784-44a2-ac19-586678f7c2f2', 8945, 'paid', '2023-06-03'), ('3958dc9e-737f-4377-85e9-fec4b6a6442a', 8945, 'paid', '2023-06-18'), ('3958dc9e-712f-4377-85e9-fec4b6a6442a', 8945, 'paid', '2023-10-04'), ('3958dc9e-737f-4377-85e9-fec4b6a6442a', 1000, 'paid', '2022-06-05') ON CONFLICT (id) DO NOTHING;

INSERT INTO revenue (month, revenue) VALUES ('Jan', 2000), ('Feb', 1800), ('Mar', 2200), ('Apr', 2500), ('May', 2300), ('Jun', 3200), ('Jul', 3500), ('Aug', 3700), ('Sep', 2500), ('Oct', 2800), ('Nov', 3000), ('Dec', 4800) ON CONFLICT (month) DO NOTHING;

INSERT INTO users (id, name, email, password) VALUES ('410544b2-4001-4271-9855-fec4b6a6442a', 'User', 'user@nextmail.com', '123456'); `

Where to add this?

vignxs commented 3 months ago

You need execute them in vercel postgres

Go to your project in vercel

You must have created postgres db for your project based on chapter 6.

If you scroll down there you'll see a box and you need click on queries then paste these one by one then execute.

Once all of them are executed you have the db ready.

Now in your local run vercel dev

That should do the work

sabaoonnayyarai commented 3 months ago

You need execute them in vercel postgres

Go to your project in vercel

You must have created postgres db for your project based on chapter 6.

If you scroll down there you'll see a box and you need click on queries then paste these one by one then execute.

Once all of them are executed you have the db ready.

Now in your local run vercel dev

That should do the work

It worked!