Skip to content

Commit

Permalink
Fix sqlite bigint primary keys
Browse files Browse the repository at this point in the history
Fixes the following error

> AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY

by applying the workaround from SeaQL/sea-orm#1832
  • Loading branch information
fgaz committed Nov 6, 2023
1 parent 7171896 commit 3a1a693
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions server/src/database/entity/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub type CacheModel = Model;
pub struct Model {
/// Unique numeric ID of the cache.
#[sea_orm(primary_key)]
// https://github.com/SeaQL/sea-orm/issues/1832
#[cfg_attr(feature = "sqlx-sqlite", sea_orm(column_type = "Integer"))]
pub id: i64,

/// Unique name of the cache.
Expand Down
2 changes: 2 additions & 0 deletions server/src/database/entity/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub enum ChunkState {
pub struct Model {
/// Unique numeric ID of the chunk.
#[sea_orm(primary_key)]
// https://github.com/SeaQL/sea-orm/issues/1832
#[cfg_attr(feature = "sqlx-sqlite", sea_orm(column_type = "Integer"))]
pub id: i64,

/// The state of the chunk.
Expand Down
2 changes: 2 additions & 0 deletions server/src/database/entity/chunkref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub type ChunkRefModel = Model;
pub struct Model {
/// Unique numeric ID of the link.
#[sea_orm(primary_key)]
// https://github.com/SeaQL/sea-orm/issues/1832
#[cfg_attr(feature = "sqlx-sqlite", sea_orm(column_type = "Integer"))]
pub id: i64,

/// ID of the NAR.
Expand Down
2 changes: 2 additions & 0 deletions server/src/database/entity/nar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ pub enum NarState {
pub struct Model {
/// Unique numeric ID of the NAR.
#[sea_orm(primary_key)]
// https://github.com/SeaQL/sea-orm/issues/1832
#[cfg_attr(feature = "sqlx-sqlite", sea_orm(column_type = "Integer"))]
pub id: i64,

/// The state of the NAR archive.
Expand Down
2 changes: 2 additions & 0 deletions server/src/database/entity/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub type ObjectModel = Model;
pub struct Model {
/// Unique numeric ID of the object.
#[sea_orm(primary_key)]
// https://github.com/SeaQL/sea-orm/issues/1832
#[cfg_attr(feature = "sqlx-sqlite", sea_orm(column_type = "Integer"))]
pub id: i64,

/// ID of the binary cache the object belongs to.
Expand Down

0 comments on commit 3a1a693

Please sign in to comment.