Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development setup: table main.users does not exist in the current database #470

Closed
kasbah opened this issue Mar 19, 2024 · 10 comments
Closed

Comments

@kasbah
Copy link

kasbah commented Mar 19, 2024

Followed the dev setup (using SQLite, btw had to edit .env.development.local as well for PRISMA_DATABASE_URL=file:///...). When I try and sign up on localhost:3000 for the first user I get:

The table `main.users` does not exist in the current database.
@Pengap
Copy link
Contributor

Pengap commented Mar 20, 2024

Execute make switch-db-mode command, how is it selected?

@kasbah
Copy link
Author

kasbah commented Mar 20, 2024

So here's how it goes when I follow the instructions exactly:

  • cd teable && corepack enable && pnpm install
    seems to work fine

  • pnpm g:build


> @teable/teable@ g:build /home/kaspar/projects/teable
> pnpm -r run build

Scope: 10 of 11 workspace projects
packages/icons build$ tsc
└─ Done in 1.7s
packages/db-main-prisma build$ tsc
│ src/prisma-manager.ts(5,15): error TS2305: Module '"@prisma/client"' has no exported membe…
│ src/prisma.service.ts(3,10): error TS2305: Module '"@prisma/client"' has no exported membe…
│ src/prisma.service.ts(4,15): error TS2305: Module '"@prisma/client"' has no exported membe…
│ src/prisma.service.ts(102,51): error TS7006: Parameter 'prisma' implicitly has an 'any' ty…
│ src/prisma.service.ts(131,16): error TS2339: Property '$connect' does not exist on type 'P…
│ src/prisma.service.ts(135,10): error TS2339: Property '$on' does not exist on type 'Prisma…
│ src/prisma.service.ts(135,30): error TS7006: Parameter 'e' implicitly has an 'any' type.
│ src/seeds/e2e/space-seeds.ts(2,15): error TS2305: Module '"../../"' has no exported member…
│ src/seeds/e2e/space-seeds.ts(55,43): error TS7006: Parameter 'tx' implicitly has an 'any' …
│ src/seeds/e2e/user-seeds.ts(3,15): error TS2305: Module '"../../"' has no exported member …
│ src/seeds/seed.abstract.ts(1,15): error TS2305: Module '"@prisma/client"' has no exported …
└─ Failed in 1.6s at /home/kaspar/projects/teable/packages/db-main-prisma
packages/core build$ tsc
└─ Running...
packages/ui-lib build$ cross-env NODE_ENV=production tsc --build tsconfig.build.json
└─ Running...
/home/kaspar/projects/teable/packages/db-main-prisma:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @teable/db-main-prisma@1.0.0 build: `tsc`
Exit status 2
 ELIFECYCLE  Command failed with exit code 1.
 
  • make switch-db-mode


Select a database to start.

1)sqlite			Lightweight embedded, ideal for mobile and embedded systems, simple, resource-efficient, easy integration (default database)
2)postges(pg)			Powerful and scalable, suitable for complex enterprise needs, highly customizable, rich community support

Enter a command: 1
make[1]: Entering directory '/home/kaspar/projects/teable'
sed: can't read s~^PRISMA_DATABASE_URL=.*~PRISMA_DATABASE_URL=file:../../db/main.db~: No such file or directory
sed: can't read s~^PRISMA_DATABASE_URL=.*~PRISMA_DATABASE_URL=file:../../db/main.db~: No such file or directory
make[1]: *** [Makefile:283: switch.prisma.env] Error 2
make[1]: Leaving directory '/home/kaspar/projects/teable'
make[1]: Entering directory '/home/kaspar/projects/teable'

> @teable/db-main-prisma@1.0.0 prisma-generate /home/kaspar/projects/teable/packages/db-main-prisma
> prisma generate "--schema" "./prisma/sqlite/schema.prisma"

Prisma schema loaded from prisma/sqlite/schema.prisma

✔ Generated Prisma Client (v5.11.0) to ./../../node_modules/.pnpm/@prisma+client@5.11.0_prisma@5.11.0/node_modules/@prisma/client in 167ms

Start using Prisma Client in Node.js (See: https://pris.ly/d/client)

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate)

import { PrismaClient } from '@prisma/client/edge'
const prisma = new PrismaClient()


See other ways of importing Prisma Client: http://pris.ly/d/importing-client

┌─────────────────────────────────────────────────────────────┐
│  Deploying your app to serverless or edge functions?        │
│  Try Prisma Accelerate for connection pooling and caching.  │
│  https://pris.ly/cli/accelerate                             │
└─────────────────────────────────────────────────────────────┘


> @teable/db-main-prisma@1.0.0 prisma-migrate /home/kaspar/projects/teable/packages/db-main-prisma
> dotenv-flow -p ../../apps/nextjs-app -- pnpm prisma migrate "deploy" "--schema" "./prisma/sqlite/schema.prisma"
Prisma schema loaded from prisma/sqlite/schema.prisma
Datasource "db": SQLite database

Error: Prisma schema validation - (get-config wasm)
Error code: P1012
error: Error validating datasource `db`: the URL must start with the protocol `file:`.
  -->  schema.prisma:9
   | 
 8 |   provider = "sqlite"
 9 |   url      = env("PRISMA_DATABASE_URL")
   | 

Validation Error Count: 1
[Context: getConfig]

Prisma CLI Version : 5.11.0
 ELIFECYCLE  Command failed with exit code 1.
make[1]: *** [Makefile:269: sqlite.mode] Error 1
make[1]: Leaving directory '/home/kaspar/projects/teable'
make: *** [Makefile:294: switch-db-mode] Error 2

@Pengap
Copy link
Contributor

Pengap commented Mar 20, 2024

Are all these actions performed in the teable project root directory?

@kasbah
Copy link
Author

kasbah commented Mar 20, 2024

That's right (except the cd teable of course). Should say: this is a fresh clone of develop branch too.

@Pengap
Copy link
Contributor

Pengap commented Mar 20, 2024

Can I see the value configured for the PRISMA_DATABASE_URL option in your .env.development file?

@kasbah
Copy link
Author

kasbah commented Mar 20, 2024

$ grep PRISMA apps/nextjs-app/.env.development 
PRISMA_DATABASE_URL=postgresql://teable:teable@127.0.0.1:5432/teable?schema=public&statement_cache_size=1

@Pengap
Copy link
Contributor

Pengap commented Mar 20, 2024


$ grep PRISMA apps/nextjs-app/.env.development 

PRISMA_DATABASE_URL=postgresql://teable:teable@127.0.0.1:5432/teable?schema=public&statement_cache_size=1

It seems that after running make switch-db-mode and selecting SQLite, the contents of the configuration file weren't automatically replaced.

Let's try manually modifying PRISMA_DATABASE_URL=file:../../db/main.db, and then run make switch-db-mode again and choose option 1.

Lastly, may I ask which operating system you are using?

@kasbah
Copy link
Author

kasbah commented Mar 20, 2024

I'm pretty sure that has made it work. After running that pnpm g:build completes too.

It seems that after running make switch-db-mode and selecting SQLite, the contents of the configuration file weren't automatically replaced.

Yep, you can see it in the log posted above:

make[1]: Entering directory '/home/kaspar/projects/teable'
sed: can't read s~^PRISMA_DATABASE_URL=.*~PRISMA_DATABASE_URL=file:../../db/main.db~: No such file or directory
sed: can't read s~^PRISMA_DATABASE_URL=.*~PRISMA_DATABASE_URL=file:../../db/main.db~: No such file or directory
make[1]: *** [Makefile:283: switch.prisma.env] Error 2
make[1]: Leaving directory '/home/kaspar/projects/teable'
make[1]: Entering directory '/home/kaspar/projects/teable'

I'm on Manjaro Linux. Maybe we are running into some sed incompatibility?

$ sed --version
sed (GNU sed) 4.9

@Pengap
Copy link
Contributor

Pengap commented Mar 21, 2024

Let's try the latest code from the branch (develop);
I've used perl to replace sed. I hope this is helpful and look forward to your reply. Thank you.

@kasbah
Copy link
Author

kasbah commented Mar 21, 2024

Seems good! Thanks!

@kasbah kasbah closed this as completed Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants