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

fix: replace file ID from i32 to i64 #325

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE TABLE file (
id SERIAL PRIMARY KEY,
id BIGSERIAL PRIMARY KEY,
account BYTEA NOT NULL,
file_key BYTEA NOT NULL,
bucket_id INTEGER NOT NULL,
Expand All @@ -20,7 +20,7 @@ CREATE INDEX idx_file_bucket_id ON file(bucket_id);
-- Create Bsp_File table
CREATE TABLE bsp_file (
bsp_id INTEGER NOT NULL,
file_id INTEGER NOT NULL,
file_id BIGINT NOT NULL,
PRIMARY KEY (bsp_id, file_id),
FOREIGN KEY (file_id) REFERENCES file(id) ON DELETE CASCADE
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE peer_id (

-- Create File_PeerId table
CREATE TABLE file_peer_id (
file_id INTEGER NOT NULL,
file_id BIGINT NOT NULL,
peer_id INTEGER NOT NULL,
PRIMARY KEY (file_id, peer_id),
FOREIGN KEY (file_id) REFERENCES file(id) ON DELETE CASCADE,
Expand Down
4 changes: 2 additions & 2 deletions client/indexer-db/src/models/bsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ impl Bsp {
#[diesel(table_name = bsp_file)]
pub struct BspFile {
pub bsp_id: i32,
pub file_id: i32,
pub file_id: i64,
}

impl BspFile {
pub async fn create<'a>(
conn: &mut DbConnection<'a>,
bsp_id: i32,
file_id: i32,
file_id: i64,
) -> Result<(), diesel::result::Error> {
diesel::insert_into(bsp_file::table)
.values((bsp_file::bsp_id.eq(bsp_id), bsp_file::file_id.eq(file_id)))
Expand Down
4 changes: 2 additions & 2 deletions client/indexer-db/src/models/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum FileStorageRequestStep {
#[diesel(table_name = file)]
pub struct File {
/// The ID of the file as stored in the database. For the runtime id, use `onchain_bsp_id`.
pub id: i32,
pub id: i64,
pub account: Vec<u8>,
pub file_key: Vec<u8>,
pub bucket_id: i32,
Expand All @@ -41,7 +41,7 @@ pub struct File {
#[diesel(belongs_to(File, foreign_key = file_id))]
#[diesel(belongs_to(crate::models::PeerId, foreign_key = peer_id))]
pub struct FilePeerId {
pub file_id: i32,
pub file_id: i64,
pub peer_id: i32,
}

Expand Down
6 changes: 3 additions & 3 deletions client/indexer-db/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ diesel::table! {
diesel::table! {
bsp_file (bsp_id, file_id) {
bsp_id -> Int4,
file_id -> Int4,
file_id -> Int8,
}
}

Expand Down Expand Up @@ -45,7 +45,7 @@ diesel::table! {

diesel::table! {
file (id) {
id -> Int4,
id -> Int8,
account -> Bytea,
file_key -> Bytea,
bucket_id -> Int4,
Expand All @@ -60,7 +60,7 @@ diesel::table! {

diesel::table! {
file_peer_id (file_id, peer_id) {
file_id -> Int4,
file_id -> Int8,
peer_id -> Int4,
}
}
Expand Down
Loading