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

Panic during SQLite migration with Teo due to reserved index name conflict #70

Closed
v423 opened this issue Jul 1, 2024 · 1 comment
Closed

Comments

@v423
Copy link

v423 commented Jul 1, 2024

I have created a join table UserAndPrescription connecting User and Prescription, but each time the project starts, this error occurs. Being less familiar with database concepts, I am unsure how to address this issue properly. Here are the details of the Teo framework version I am using:

enviroment:
nodejs: 22.0.0
@teocloud/teo: 0.2.36

error

sqlite connector connected for `main` at "sqlite:medicine.sqlite"
thread 'tokio-runtime-worker' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/teo-sql-connector-0.2.32/src/migration/migrate.rs:202:73:
called `Result::unwrap()` on an `Err` value: Error { kind: QueryError(SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some("object name reserved for internal use: sqlite_autoindex_UserAndPrescription_1"))), original_code: Some("1"), original_message: Some("object name reserved for internal use: sqlite_autoindex_UserAndPrescription_1") }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

code

connector {
  provider: .sqlite,
  url: "sqlite:medicine.sqlite"
}

server {
  bind:("0.0.0.0", 8088)
}

model User{
  @id @autoIncrement @readonly
  id: Int 
  name: String
  
  @relation(through:UserAndPrescription, local: .user, foreign: .prescription)
  prescriptions: Prescription[]
}


model Prescription{
  @id @autoIncrement @readonly
  id: Int 

  title: String 
  note: String? 

  start_date: Int
  end_date: Int?
  
  @relation(through:UserAndPrescription, local: .prescription, foreign: .user)
  users: User[] 
  
}

@id([.userId, .prescriptionId])
model UserAndPrescription{
  @foreignKey
  userId: Int
  @foreignKey
  prescriptionId: Int

  @relation(fields: .userId, references: .id)
  user: User
  @relation(fields: .prescriptionId, references: .id)
  prescription: Prescription
}

@victorteokw
Copy link
Collaborator

Hi @v423, this bug is fixed in the 0.3.0-alpha development version.

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