You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This is rare, we don't worry about optimizing this.
141
136
142
137
current_version_stmt.reset()?;
143
138
144
139
let down_migrations_stmt = local_db.prepare_v2("select e.value ->> 'sql' as sql from (select id, down_migrations from ps_migration where id > ?1 order by id desc limit 1) m, json_each(m.down_migrations) e")?;
145
-
down_migrations_stmt.bind_int(1,CODE_VERSION)?;
140
+
down_migrations_stmt.bind_int(1,target_version)?;
146
141
147
142
letmut down_sql:Vec<String> = alloc::vec![];
148
143
@@ -151,14 +146,71 @@ CREATE TABLE IF NOT EXISTS ps_migration(id INTEGER PRIMARY KEY, down_migrations
151
146
down_sql.push(sql.to_string());
152
147
}
153
148
149
+
if current_version == 5{
150
+
down_sql.push(
151
+
"\
152
+
ALTER TABLE ps_buckets RENAME TO ps_buckets_5;
153
+
ALTER TABLE ps_oplog RENAME TO ps_oplog_5;
154
+
155
+
CREATE TABLE ps_buckets(
156
+
name TEXT PRIMARY KEY,
157
+
last_applied_op INTEGER NOT NULL DEFAULT 0,
158
+
last_op INTEGER NOT NULL DEFAULT 0,
159
+
target_op INTEGER NOT NULL DEFAULT 0,
160
+
add_checksum INTEGER NOT NULL DEFAULT 0,
161
+
pending_delete INTEGER NOT NULL DEFAULT 0
162
+
, op_checksum INTEGER NOT NULL DEFAULT 0, remove_operations INTEGER NOT NULL DEFAULT 0);
163
+
164
+
INSERT INTO ps_buckets(name, last_applied_op, last_op, target_op, add_checksum, op_checksum, pending_delete)
165
+
SELECT name, last_applied_op, last_op, target_op, add_checksum, op_checksum, pending_delete FROM ps_buckets_5;
166
+
167
+
CREATE TABLE ps_oplog(
168
+
bucket TEXT NOT NULL,
169
+
op_id INTEGER NOT NULL,
170
+
op INTEGER NOT NULL,
171
+
row_type TEXT,
172
+
row_id TEXT,
173
+
key TEXT,
174
+
data TEXT,
175
+
hash INTEGER NOT NULL,
176
+
superseded INTEGER NOT NULL);
177
+
178
+
CREATE INDEX ps_oplog_by_row ON ps_oplog (row_type, row_id) WHERE superseded = 0;
179
+
CREATE INDEX ps_oplog_by_opid ON ps_oplog (bucket, op_id);
180
+
CREATE INDEX ps_oplog_by_key ON ps_oplog (bucket, key) WHERE superseded = 0;
0 commit comments