activerecord-beagle-turso 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0a1a95bf62c876f996098db6a065aa9157af882b13d5038c7a86226ea6514b8b
|
|
4
|
+
data.tar.gz: 36d1eb3bdaf31d214ca80a1ab3754323cec795172bf00e2bcfd78d6812a7b3d7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab8346581f6054cec006ab218b12e03db82b4dde79f5afe3093fee8ccfc8e3116f5dc82b4152cccaac0415c449a19a4fbe4343cf6bfc34c11992eb3a7ee6b925
|
|
7
|
+
data.tar.gz: 83ba09effe58a3c3598034db2982ab7f6a0037da1b4beeefea01db6b57c1ffc94de39b8ebf6b9bd09af87da48d94a2cbffdbe2445e911270c7e293f416f8eade
|
data/README.md
CHANGED
|
@@ -67,6 +67,8 @@ An optional `bootstrap_if_empty:` (default `true`) controls whether a brand
|
|
|
67
67
|
new/empty local file is populated from the remote on first open — see
|
|
68
68
|
`Beagle::Turso::Database.open`.
|
|
69
69
|
|
|
70
|
+
The sync engine's own tables (`turso_cdc`, `turso_cdc_version`, `turso_sync_last_change_id`) are hidden from `connection.tables`/`data_sources` and therefore from schema dumps and table-truncating tooling.
|
|
71
|
+
|
|
70
72
|
### Durability note: writes commit on-sync, not synchronously
|
|
71
73
|
|
|
72
74
|
Writes go to the **local** file immediately, as part of the normal
|
|
@@ -94,7 +96,7 @@ All three default their `connection` argument to `ActiveRecord::Base.connection`
|
|
|
94
96
|
so `Beagle::Turso::SyncManager.sync!` alone is the usual call. Calling any of
|
|
95
97
|
them against a **local-only** connection (no `remote_url:`/`auth_token:` in
|
|
96
98
|
`database.yml`) raises `Beagle::Turso::SyncManager::NotSyncedError` — a
|
|
97
|
-
distinct, rescuable type — rather than the driver's
|
|
99
|
+
distinct, rescuable type — rather than the driver's own `Beagle::Turso::NotSyncedError`.
|
|
98
100
|
|
|
99
101
|
To sync on a timer, wire
|
|
100
102
|
`ActiveRecord::ConnectionAdapters::BeagleTurso::SyncJob` (a thin delegator to
|
|
@@ -46,23 +46,14 @@ module Beagle
|
|
|
46
46
|
module SyncManager
|
|
47
47
|
# Raised by +push!+/+pull!+/+sync!+ when the given connection is
|
|
48
48
|
# local-only (its database.yml entry has no +remote_url+/+auth_token+,
|
|
49
|
-
# so BeagleTursoAdapter opened it via +Database.open_local+). The
|
|
50
|
-
#
|
|
51
|
-
# this (
|
|
52
|
-
# it as this distinct, documented type so callers can rescue it
|
|
53
|
-
# specifically instead of matching on the driver's message text. A
|
|
49
|
+
# so BeagleTursoAdapter opened it via +Database.open_local+). The driver
|
|
50
|
+
# raises Beagle::Turso::NotSyncedError for this; SyncManager re-raises it
|
|
51
|
+
# as this type (kept for compatibility) with a database.yml hint. A
|
|
54
52
|
# genuine sync failure against a real remote (network error, auth
|
|
55
|
-
# failure, etc.) is NOT reclassified -- it propagates as
|
|
56
|
-
#
|
|
53
|
+
# failure, etc.) is NOT reclassified -- it propagates as
|
|
54
|
+
# Beagle::Turso::SyncError (or another Beagle::Turso::Error), unchanged.
|
|
57
55
|
class NotSyncedError < StandardError; end
|
|
58
56
|
|
|
59
|
-
# Matches only the driver's local-only wording (see
|
|
60
|
-
# beagle_turso_core's `Error::Sync` in `Database::push`/`Database::pull`)
|
|
61
|
-
# so a real sync failure -- which also surfaces as a RuntimeError, just
|
|
62
|
-
# with different text -- is never misreported as "not synced".
|
|
63
|
-
LOCAL_ONLY_MESSAGE_REGEX = /on a local-only database/i
|
|
64
|
-
private_constant :LOCAL_ONLY_MESSAGE_REGEX
|
|
65
|
-
|
|
66
57
|
module_function
|
|
67
58
|
|
|
68
59
|
# Push this connection's local writes to its remote Turso database.
|
|
@@ -88,9 +79,7 @@ module Beagle
|
|
|
88
79
|
|
|
89
80
|
def reraise_local_only
|
|
90
81
|
yield
|
|
91
|
-
rescue
|
|
92
|
-
raise e unless LOCAL_ONLY_MESSAGE_REGEX.match?(e.message)
|
|
93
|
-
|
|
82
|
+
rescue Beagle::Turso::NotSyncedError => e
|
|
94
83
|
raise NotSyncedError,
|
|
95
84
|
"#{e.message} -- this connection is local-only; configure remote_url: " \
|
|
96
85
|
"and auth_token: in database.yml to enable sync"
|
|
@@ -219,8 +219,21 @@ module ActiveRecord
|
|
|
219
219
|
# `create_table "__turso_internal_seq_..."` block per table into
|
|
220
220
|
# db/schema.rb, and the next `db:schema:load` tries to create them for
|
|
221
221
|
# real.
|
|
222
|
+
#
|
|
223
|
+
# On a synced replica the sync engine also keeps its change log in
|
|
224
|
+
# three tables (`turso_cdc`, `turso_cdc_version`,
|
|
225
|
+
# `turso_sync_last_change_id`). They are matched by EXACT name so a user
|
|
226
|
+
# table such as `turso_sync_log` stays visible. Left unfiltered,
|
|
227
|
+
# `db:schema:dump` would dump them and `db:truncate_all`, fixtures or
|
|
228
|
+
# DatabaseCleaner truncation would wipe the change log (losing unpushed
|
|
229
|
+
# sync data).
|
|
230
|
+
SYNC_ENGINE_TABLES = %w[turso_cdc turso_cdc_version turso_sync_last_change_id].freeze
|
|
231
|
+
private_constant :SYNC_ENGINE_TABLES
|
|
232
|
+
|
|
222
233
|
def data_source_sql(name = nil, type: nil)
|
|
223
|
-
|
|
234
|
+
hidden = SYNC_ENGINE_TABLES.map { |t| quote(t) }.join(", ")
|
|
235
|
+
"#{super} AND name NOT LIKE '\\_\\_turso\\_internal\\_%' ESCAPE '\\'" \
|
|
236
|
+
" AND name NOT IN (#{hidden})"
|
|
224
237
|
end
|
|
225
238
|
|
|
226
239
|
# A column definition in the DDL that carries a parenthesised type
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-beagle-turso
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- BeagleSoftwareUK
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0.
|
|
33
|
+
version: '0.2'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0.
|
|
40
|
+
version: '0.2'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: sqlite3
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|