activerecord-virgodb-adapter 0.1.6 → 0.1.7
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 +29 -5
- 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: d70a70ab0e46de3acd4d283c69e7c385873c7bb9ec817423f62ff09dbc601350
|
|
4
|
+
data.tar.gz: 1f7b6259306a3d61f2e3d05fb345373a5d350b2742309804be1d91ac096886a1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 64c5716aa1f9d1ea110aacd562ad131acb5d8d76bbd4e8d0ed459a2191530d7b27c6c1f924b59a70840defed6f285c668e6fc9a56f97b134719bd2033ed42b6f
|
|
7
|
+
data.tar.gz: 9f2de20a524c86e2bafc0a43b6f49b8d86bdf127a54b8a5276972f75b10e937c5c7fe3b89b88172eaca32b4aaee09aa0aa52a34f947c614dc3926c3d1878f82e
|
|
@@ -74,6 +74,7 @@ module ActiveRecord
|
|
|
74
74
|
super
|
|
75
75
|
strip_null_autoindex_blank_lines!(filename)
|
|
76
76
|
reformat_create_table_statements!(filename)
|
|
77
|
+
separate_create_table_statements_with_blank_lines!(filename)
|
|
77
78
|
annotate_physical_layout!(filename)
|
|
78
79
|
dump_schema_versions!(filename)
|
|
79
80
|
end
|
|
@@ -217,11 +218,11 @@ module ActiveRecord
|
|
|
217
218
|
# `ignore_tables` is empty) already skips these rows itself --
|
|
218
219
|
# confirmed empirically too -- so this is purely a gap in the
|
|
219
220
|
# raw-SQL fallback, not something either path does on purpose.
|
|
220
|
-
# Stripping now, before `reformat_create_table_statements!`
|
|
221
|
-
#
|
|
222
|
-
#
|
|
223
|
-
#
|
|
224
|
-
#
|
|
221
|
+
# Stripping now, before `reformat_create_table_statements!` and
|
|
222
|
+
# `separate_create_table_statements_with_blank_lines!` (below) touch
|
|
223
|
+
# anything, gives those steps a clean slate -- every blank line in the
|
|
224
|
+
# dump from this point on is one THEY deliberately added, not this
|
|
225
|
+
# accidental one.
|
|
225
226
|
def strip_null_autoindex_blank_lines!(filename)
|
|
226
227
|
content = File.read(filename)
|
|
227
228
|
content.gsub!(/\n\n+/, "\n")
|
|
@@ -268,6 +269,29 @@ module ActiveRecord
|
|
|
268
269
|
File.write(filename, content)
|
|
269
270
|
end
|
|
270
271
|
|
|
272
|
+
# Matches `db/clickhouse_structure.sql` and `db/schema.rb`'s own
|
|
273
|
+
# convention (both, unprompted, separate every top-level table
|
|
274
|
+
# definition with a blank line -- confirmed directly against
|
|
275
|
+
# hintpot's real dumps of each, not assumed) rather than inventing a
|
|
276
|
+
# new one here. Only CREATE TABLE gets a leading blank line, not
|
|
277
|
+
# CREATE INDEX/CREATE UNIQUE INDEX -- those stay glued directly under
|
|
278
|
+
# their own table, same as clickhouse_structure.sql has no equivalent
|
|
279
|
+
# to disagree with and virgodb's own tables (e.g. `inline_batches` +
|
|
280
|
+
# `idx_inline_batches_table_name`) already read naturally that way.
|
|
281
|
+
# Runs after `reformat_create_table_statements!` (so every `CREATE
|
|
282
|
+
# TABLE` is unambiguously alone at the start of its own line already,
|
|
283
|
+
# nothing left to normalize first) but before
|
|
284
|
+
# `annotate_physical_layout!` (so a table WITH a physical-layout
|
|
285
|
+
# comment gets the blank line ahead of the comment block, not
|
|
286
|
+
# wedged between the comment and its own `CREATE TABLE`).
|
|
287
|
+
# `(?<!\A)` skips the very first statement in the file, which should
|
|
288
|
+
# start right at the top with no leading blank line.
|
|
289
|
+
def separate_create_table_statements_with_blank_lines!(filename)
|
|
290
|
+
content = File.read(filename)
|
|
291
|
+
content.gsub!(/(?<!\A)^CREATE TABLE /) { |match| "\n#{match}" }
|
|
292
|
+
File.write(filename, content)
|
|
293
|
+
end
|
|
294
|
+
|
|
271
295
|
# Splits a CREATE TABLE column list on commas that are NOT nested
|
|
272
296
|
# inside a type's own parens (e.g. `Decimal(18,2)`) -- a plain
|
|
273
297
|
# `String#split(",")` would wrongly cut `Decimal(18` and `2)` apart.
|