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

Use one migration instead of two #231

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 7 additions & 9 deletions crates/corro-types/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ pub fn migrate(clock: Arc<uhlc::HLC>, conn: &mut Connection) -> rusqlite::Result
Box::new(crsqlite_v0_16_migration as fn(&Transaction) -> rusqlite::Result<()>),
Box::new(create_bookkeeping_gaps as fn(&Transaction) -> rusqlite::Result<()>),
Box::new(create_impacted_versions as fn(&Transaction) -> rusqlite::Result<()>),
Box::new(create_ts_index_bookkeeping_table),
Box::new(create_sync_state(clock)),
];

Expand Down Expand Up @@ -360,21 +359,20 @@ fn refactor_corro_members(tx: &Transaction) -> rusqlite::Result<()> {
)
}

fn create_ts_index_bookkeeping_table(tx: &Transaction) -> rusqlite::Result<()> {
tx.execute_batch(
r#"
fn create_sync_state(clock: Arc<uhlc::HLC>) -> impl Fn(&Transaction) -> rusqlite::Result<()> {
let ts = Timestamp::from(clock.new_timestamp());

move |tx: &Transaction| -> rusqlite::Result<()> {
tx.execute_batch(
r#"
CREATE INDEX index__corro_bookkeeping_ts ON __corro_bookkeeping (actor_id, ts ASC);
CREATE TABLE __corro_sync_state (
actor_id BLOB PRIMARY KEY NOT NULL,
last_cleared_ts TEXT
);
"#,
)
}
fn create_sync_state(clock: Arc<uhlc::HLC>) -> impl Fn(&Transaction) -> rusqlite::Result<()> {
let ts = Timestamp::from(clock.new_timestamp());
)?;

move |tx: &Transaction| -> rusqlite::Result<()> {
tx.execute(
r#"
UPDATE __corro_bookkeeping SET ts = ?
Expand Down
Loading