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
// We can replace this with actual similated download operations later
34
46
db.execute('''
35
47
BEGIN TRANSACTION;
36
48
37
49
WITH RECURSIVE generate_rows(n) AS (
38
50
SELECT 1
39
51
UNION ALL
40
-
SELECT n + 1 FROM generate_rows WHERE n < 200000
52
+
SELECT n + 1 FROM generate_rows WHERE n < $count
41
53
)
42
54
INSERT INTO ps_oplog (bucket, op_id, row_type, row_id, key, data, hash)
43
55
SELECT
44
-
(n % 10), -- Generate 10 different buckets
56
+
(n % $buckets), -- Generate n different buckets
45
57
n,
46
58
'assets',
47
-
uuid(),
59
+
${unique ? 'uuid()' : "'duplicated_id'"},
48
60
uuid(),
49
61
'{"description": "' || n || '", "make": "test", "model": "this is just filler data. this is just filler data. this is just filler data. this is just filler data. this is just filler data. this is just filler data. this is just filler data. "}',
50
62
(n * 17) % 1000000000 -- Some pseudo-random hash
51
63
52
64
FROM generate_rows;
53
65
54
-
WITH RECURSIVE generate_rows(n) AS (
66
+
WITH RECURSIVE generate_bucket_rows(n) AS (
55
67
SELECT 1
56
68
UNION ALL
57
-
SELECT n + 1 FROM generate_rows WHERE n < 10
69
+
SELECT n + 1 FROM generate_bucket_rows WHERE n < $buckets
58
70
)
59
71
INSERT INTO ps_buckets (id, name, last_applied_op)
60
72
SELECT
61
-
(n % 10),
73
+
(n % $buckets),
62
74
'bucket' || n,
63
-
10000
75
+
$alreadyApplied -- simulate a percentage of operations previously applied
64
76
65
-
FROM generate_rows;
77
+
FROM generate_bucket_rows;
66
78
67
79
COMMIT;
68
80
''');
@@ -76,6 +88,11 @@ COMMIT;
76
88
db.select('insert into powersync_operations(op, data) values(?, ?)',
0 commit comments