activerecord-virgodb-adapter 0.1.4 → 0.1.5
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 +4 -4
- data/lib/active_record/tasks/virgodb_database_tasks.rb +27 -11
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 19cfa01c6fa3ae36139e4412c022abfe3039c670fd4b29fbffdb399f47c8c36d
|
|
4
|
+
data.tar.gz: 5180372a507b33cd5a51670c3439894efafd72ca8d22538efc5b0a738eeb3937
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ffee29b035fe6705dd22022056b35e281f4275c9e009075508d136e87b03e804e62db4052ac8d581a010a50036568a6a6299ee7aa03f33137a56c28532b9a81
|
|
7
|
+
data.tar.gz: 5303c2ceaf69703a4739614f76fd518741ea4555b18cc3bab4276d19c04189e03a9d192b8402dde926f235136bf87ac5e361a331f9e2efc7510f33d761fd19eb
|
|
@@ -197,20 +197,36 @@ module ActiveRecord
|
|
|
197
197
|
# `SQLite3Adapter#structure_dump`'s raw `SELECT sql FROM sqlite_master`
|
|
198
198
|
# path (used whenever `ActiveRecord::SchemaDumper.ignore_tables` is
|
|
199
199
|
# non-empty, e.g. excluding tables owned by a separate replication/
|
|
200
|
-
# backup mechanism) reproduces each
|
|
201
|
-
#
|
|
202
|
-
#
|
|
203
|
-
#
|
|
204
|
-
#
|
|
205
|
-
#
|
|
206
|
-
#
|
|
200
|
+
# backup mechanism) reproduces each CREATE TABLE exactly as SQLite
|
|
201
|
+
# stored it -- one long line, every column crammed together, for a
|
|
202
|
+
# table ActiveRecord generated. Fine for SQLite to load back
|
|
203
|
+
# (structure_load doesn't care about whitespace), useless to a human
|
|
204
|
+
# reading the dump next to `db/clickhouse_structure.sql` (ClickHouse's
|
|
205
|
+
# own `SHOW CREATE TABLE` is naturally one-column-per-line, for
|
|
206
|
+
# comparison). Purely cosmetic, safe to do unconditionally: only
|
|
207
207
|
# rewrites the exact same statement with different whitespace, no DDL
|
|
208
|
-
# semantics change.
|
|
209
|
-
#
|
|
210
|
-
#
|
|
208
|
+
# semantics change.
|
|
209
|
+
#
|
|
210
|
+
# Must handle statements that ALREADY span multiple lines, not just
|
|
211
|
+
# single-line ones: every virgodb-side manifest table (`crates/
|
|
212
|
+
# manifest/src/lib.rs`'s `maintenance_lease`, `orphaned_files`, this
|
|
213
|
+
# adapter's own `schema_versions`, ...) is bootstrapped from a
|
|
214
|
+
# multi-line, already-indented `CREATE TABLE` literal, and any column
|
|
215
|
+
# added to one of those later via `ALTER TABLE ... ADD COLUMN` (the
|
|
216
|
+
# only way SQLite can add a column to an existing table) gets its
|
|
217
|
+
# definition spliced into that SAME stored multi-line text, right
|
|
218
|
+
# before the final `)` -- with none of the original literal's
|
|
219
|
+
# indentation, producing exactly the lopsided
|
|
220
|
+
# "seven clean columns, then a cramped `, col1, col2)` tail" shape a
|
|
221
|
+
# single-line-only regex would silently skip over and leave raw.
|
|
222
|
+
# `/m` (dot matches newline) plus a non-greedy `(.*?)` is required
|
|
223
|
+
# together: `/m` alone with the old greedy `(.*)` would swallow every
|
|
224
|
+
# later `CREATE TABLE`/`CREATE INDEX` statement up to the LAST `);` in
|
|
225
|
+
# the file into one match, since nothing would stop it at the nearer
|
|
226
|
+
# one.
|
|
211
227
|
def reformat_create_table_statements!(filename)
|
|
212
228
|
content = File.read(filename)
|
|
213
|
-
content.gsub!(/^CREATE TABLE (IF NOT EXISTS )?("[\w]+"|\w+) \((
|
|
229
|
+
content.gsub!(/^CREATE TABLE (IF NOT EXISTS )?("[\w]+"|\w+) \((.*?)\);$/m) do
|
|
214
230
|
if_not_exists = Regexp.last_match(1)
|
|
215
231
|
table_name = Regexp.last_match(2)
|
|
216
232
|
columns = split_top_level_commas(Regexp.last_match(3))
|