Skip to content

Commit 7d76ee3

Browse files
committed
support artifact_size (sqlite to postgres)
1 parent 2dbb06b commit 7d76ee3

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

database/src/bin/sqlite-to-postgres.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,43 @@ impl Table for RuntimePstatSeries {
569569
}
570570
}
571571

572+
struct ArtifactSize;
573+
574+
#[derive(Serialize)]
575+
struct ArtifactSizeRow<'a> {
576+
aid: i32,
577+
component: &'a str,
578+
size: i32,
579+
}
580+
581+
impl Table for ArtifactSize {
582+
fn name() -> &'static str {
583+
"artifact_size"
584+
}
585+
586+
fn sqlite_attributes() -> &'static str {
587+
"aid, component, size"
588+
}
589+
590+
fn postgres_attributes() -> &'static str {
591+
"aid, component, size"
592+
}
593+
594+
fn postgres_generated_id_attribute() -> Option<&'static str> {
595+
None
596+
}
597+
598+
fn write_postgres_csv_row<W: Write>(writer: &mut csv::Writer<W>, row: &rusqlite::Row) {
599+
writer
600+
.serialize(ArtifactSizeRow {
601+
aid: row.get(0).unwrap(),
602+
component: row.get_ref(1).unwrap().as_str().unwrap(),
603+
size: row.get(2).unwrap(),
604+
})
605+
.unwrap();
606+
}
607+
}
608+
572609
// `Nullable<T>` helps to work around the fact that the `csv` crate (and the CSV
573610
// format in general) doesn't distinguish between nulls and empty strings, while
574611
// the Postgres CSV format does.
@@ -699,6 +736,7 @@ async fn main() -> anyhow::Result<()> {
699736
copy::<RustcCompilation>(&sqlite_tx, &postgres_tx).await;
700737
copy::<RuntimePstatSeries>(&sqlite_tx, &postgres_tx).await;
701738
copy::<RuntimePstat>(&sqlite_tx, &postgres_tx).await;
739+
copy::<ArtifactSize>(&sqlite_tx, &postgres_tx).await;
702740
enable_table_triggers(&postgres_tx, &tables).await;
703741

704742
// This is overly paranoid, but don't commit the Postgres transaction until

0 commit comments

Comments
 (0)