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

"there is no unique or exclusion constraint matching the ON CONFLICT specification" #92

Closed
NathanFlurry opened this issue Apr 23, 2023 · 6 comments
Labels
bug Something isn't working self-hosting Forks; Railway; DigitalOcean; environment variables; Docker

Comments

@NathanFlurry
Copy link

I deployed 06f4b61 to Railway. After linking both my Linear and my GitHub, I get the following error:

Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42P10), message: "there is no unique or exclusion constraint matching the ON CONFLICT specification", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("plancat.c"), line: Some(835), routine: Some("infer_arbiter_indexes") }) }), transient: false })
Error saving sync:
Invalid `prisma.sync.upsert()` invocation:

Running SELECT version(); on Postgres returns:

PostgreSQL 13.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 64-bit

I'm using OAuth for SyncLinear.

Any idea what might be going on?

@maige-app maige-app bot added the bug Something isn't working label Apr 23, 2023
@tedspare
Copy link
Collaborator

Thanks @NathanFlurry - not sure. @rijkvanzanten any ideas?

@rijkvanzanten
Copy link
Contributor

SqlState(E42P10), message: "there is no unique or exclusion constraint matching the ON CONFLICT specification"

That to me sounds like something somewhere is trying to trigger a on-conflict handler on a column that doesn't have a unique index in the database. Hard to tell without a more in-depth reproducible example. From what I can tell, there's no ON CONFLICT rules defined within this codebase, so I'm not sure where that's supposed to come from. What exact steps did you take to install synclinear @NathanFlurry?

@tedspare
Copy link
Collaborator

Hey @NathanFlurry - the uniqueness constraint it should be looking for on sync is in the schema here, so I wonder if I missed a SQL migration that creates that index.

Did you run npx prisma migrate dev and npx prisma generate from the self-hosting guide here?

@NathanFlurry
Copy link
Author

@tedspare @rijkvanzanten Apologies for the slow response, I had to refresh my memory and start from scratch.

prisma generate should be automatically ran from the pnpm run build step in the Dockerfile.

I just tried this again off of 7b7e9e6 with a fresh Railway app & database. Here are the steps to reproduce the error:

  1. I clicked the "Deploy to Railway" button
  2. For the env:
  • Deleted LINEAR_API_KEY and GITHUB_API_KEY
  • Populated LINEAR_OAUTH_SCRET, NEXT_PUBLIC_LINEAR_OAUTH_ID, GITHUB_OAUTH_SECRET, and NEXT_PUBLIC_GITHUB_OAUTH_ID
  1. Update the Dockerfile as such:
RUN npm i -g prisma

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /synclinear/public ./public
+ COPY --from=builder --chown=nextjs:nodejs /synclinear/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /synclinear/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /synclinear/prisma ./prisma

USER nextjs

EXPOSE 3000

ENV PORT 3000

- CMD ["node", "server.js"]
+ CMD ["sh", "-c", "prisma migrate deploy && node server.js"]
  1. Link my Linear & click "deploy webhook" (which succeeds)
  2. Link my Github
  3. Click "deploy webhook," which presents this error:
Failed to save sync with error: 
Invalid `prisma.sync.upsert()` invocation:


Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42P10), message: "there is no unique or exclusion constraint matching the ON CONFLICT specification", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("plancat.c"), line: Some(835), routine: Some("infer_arbiter_indexes") }) }), transient: false })

@tedspare
Copy link
Collaborator

/label

@maige-app maige-app bot added the self-hosting Forks; Railway; DigitalOcean; environment variables; Docker label Jul 11, 2023
@tedspare
Copy link
Collaborator

I believe this was fixed in #131 thanks to @yorik 🎉

Please let me know if not!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working self-hosting Forks; Railway; DigitalOcean; environment variables; Docker
Projects
None yet
Development

No branches or pull requests

3 participants