lachlanjc / predictcovid

Visualize & track the 2020 COVID-19 pandemic by country.
https://predictcovid.netlify.app/
MIT License
111 stars 11 forks source link

Can't setup dev sqlite database #7

Closed arcontechnologies closed 4 years ago

arcontechnologies commented 4 years ago

Hi,

I do not know yarn and nodejs. So I installed both of them and modules were instralled by after. The issue I'm facing is when I'm running : yarn redwood db seed

it tells me :

PrismaClientUnknownRequestError:
Invalid db.country.create() invocation in
C:\Users\albel\Documents\covid19\api\prisma\seeds.js:64:22

   60 }
   61
   62 async function main() {
   63   await asyncForEach(countries, async (country) => {
→  64     await db.country.create(

Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some("no such table: C:.Country"))) })
    at PrismaClientFetcher.request (C:\Users\albel\Documents\covid19\node_modules\@prisma\client\index.js:90:17)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
Seeding your database... [completed]
Done in 1.86s.

the schema.prisma looks like this

datasource DS {
  provider = "sqlite"
  url = "file:dev.db"
}

generator photonjs {
  provider = "prisma-client-js"
  binaryTargets = ["native", "rhel-openssl-1.0.x"]
}

model Day {
  id Int @id @default(autoincrement())
  date DateTime @unique
  createdAt DateTime @default(now())
  counts DailyCount[]
}

model Country {
  id Int @id @default(autoincrement())
  iso String @unique
  worldometersSlug String @unique
  name String
  createdAt DateTime @default(now())
  dailyCounts DailyCount[]
}

model DailyCount {
  id Int @id @default(autoincrement())
  date Day
  country Country
  totalCases Int
  newCases Int
  currentlyInfected Int
  totalDeaths Int
  newDeaths Int
}

How can I add a new country ?

Any insight on what I doing wrong ? thanks

zachlatta commented 4 years ago

Hey, if you're looking to get the app running locally, you need to edit the schema.prisma file to look like this at the top:

datasource DS {
  provider = "sqlite"
  url = env("DATABASE_URL")
}

To add a new country, Worldometers scraping is currently broken. Can you assist in #4?