Skip to content

Commit

Permalink
metadata: Rename indexes table into index_files
Browse files Browse the repository at this point in the history
  • Loading branch information
tontinton committed May 31, 2024
1 parent 4ac33f9 commit 21c0cf9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions migrations/0001_index_files.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE index_files;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS indexes(
CREATE TABLE IF NOT EXISTS index_files(
id VARCHAR(36) PRIMARY KEY,
file_name TEXT NOT NULL,
footer_len BIGINT NOT NULL
Expand Down
1 change: 0 additions & 1 deletion migrations/0001_indexes.down.sql

This file was deleted.

6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async fn open_unified_directories(
index_dir: &str,
pool: &PgPool,
) -> Result<Vec<(String, UnifiedDirectory)>> {
let items = query!("SELECT id, file_name, footer_len FROM indexes")
let items = query!("SELECT id, file_name, footer_len FROM index_files")
.fetch_all(pool)
.await?;

Expand Down Expand Up @@ -135,7 +135,7 @@ async fn write_unified_index(
let (total_len, footer_len) = unified_index_writer.write(&mut writer, file_cache).await?;
writer.shutdown().await?;

query("INSERT INTO indexes (id, file_name, footer_len) VALUES ($1, $2, $3)")
query("INSERT INTO index_files (id, file_name, footer_len) VALUES ($1, $2, $3)")
.bind(&id.to_string())
.bind(&file_name)
.bind(footer_len as i64)
Expand Down Expand Up @@ -238,7 +238,7 @@ async fn merge(args: MergeArgs, pool: PgPool, index_dir: &str) -> Result<()> {

write_unified_index(index, &args.merge_dir, index_dir, &pool).await?;

let delete_result = query("DELETE FROM indexes WHERE id = ANY($1)")
let delete_result = query("DELETE FROM index_files WHERE id = ANY($1)")
.bind(&ids)
.execute(&pool)
.await;
Expand Down

0 comments on commit 21c0cf9

Please sign in to comment.