exwiw 0.4.3 → 0.4.4
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/CHANGELOG.md +6 -0
- data/lib/exwiw/adapter/mysql_adapter.rb +12 -1
- data/lib/exwiw/adapter.rb +8 -0
- data/lib/exwiw/runner.rb +4 -0
- data/lib/exwiw/version.rb +1 -1
- 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: '028047197ff7f7e93fdda9b7ca4ad934da9ac904c53bc7859da113f89710de23'
|
|
4
|
+
data.tar.gz: 2e7ef72dd106f3133ab6ba35b752c5c961fb02da02b98ede71400285fc36a2e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f33e62a4df3f5bacfb20a20bb18defcb3e6296a404981afa4b5ace3ac2153fa58f408cbea8fbf5aea83da66dbec3513c49c16ae6670324cebf767cfe0894c870
|
|
7
|
+
data.tar.gz: 2395aed648209edde5afa7a38bae47088e9327e562f42c166ec259d69aba270fb3689d3b472aeffdfbc185dc8b30501b2963e28c301d4f04b90c56b815ae65ba
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.4.4] - 2026-06-05
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- MySQL: generated schema and data files now wrap statements with `SET FOREIGN_KEY_CHECKS=0` / restore, following the `mysqldump` save/restore convention (`@OLD_FOREIGN_KEY_CHECKS`). Previously the FK check preamble was lost when exwiw split `mysqldump` output into per-file schema and data files, causing `Failed to open the referenced table` errors on restore when CREATE TABLE or INSERT order didn't satisfy FK dependencies. Each file is now self-contained and restorable regardless of load order. ([#81](https://github.com/heyinc/exwiw/pull/81))
|
|
10
|
+
|
|
5
11
|
## [0.4.3] - 2026-06-05
|
|
6
12
|
|
|
7
13
|
### Fixed
|
|
@@ -83,11 +83,22 @@ module Exwiw
|
|
|
83
83
|
|
|
84
84
|
File.open(output_path, 'w') do |file|
|
|
85
85
|
file.puts("-- Auto-generated by exwiw via mysqldump. Idempotent CREATE TABLE statements for mysql.")
|
|
86
|
-
file.
|
|
86
|
+
file.puts("SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;")
|
|
87
|
+
file.puts
|
|
88
|
+
file.puts(idempotent)
|
|
89
|
+
file.puts("SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;")
|
|
87
90
|
end
|
|
88
91
|
@logger.info(" Wrote schema for #{table_names.size} table(s) to #{output_path}.")
|
|
89
92
|
end
|
|
90
93
|
|
|
94
|
+
def pre_insert_sql(_table)
|
|
95
|
+
"SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;"
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def post_insert_sql(_table)
|
|
99
|
+
"SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;"
|
|
100
|
+
end
|
|
101
|
+
|
|
91
102
|
def to_bulk_insert(results, table)
|
|
92
103
|
table_name = table.name
|
|
93
104
|
|
data/lib/exwiw/adapter.rb
CHANGED
|
@@ -93,6 +93,14 @@ module Exwiw
|
|
|
93
93
|
def validate_as_dump_target!(_config)
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
+
# Optional SQL prepended to the per-table insert-NNN-<table>.* file before
|
|
97
|
+
# the bulk INSERT/COPY statements. Use for session-level setup required
|
|
98
|
+
# before loading data (e.g. MySQL FOREIGN_KEY_CHECKS).
|
|
99
|
+
# Default: nil (nothing prepended).
|
|
100
|
+
def pre_insert_sql(_table)
|
|
101
|
+
nil
|
|
102
|
+
end
|
|
103
|
+
|
|
96
104
|
# Optional SQL appended to the per-table insert-NNN-<table>.* file after
|
|
97
105
|
# the bulk INSERT statements. Use to bring side-state in sync with the
|
|
98
106
|
# explicit IDs that were just inserted (e.g. PostgreSQL sequences).
|
data/lib/exwiw/runner.rb
CHANGED
|
@@ -83,6 +83,8 @@ module Exwiw
|
|
|
83
83
|
@logger.info(" Generated COPY statement for #{record_num} records.")
|
|
84
84
|
|
|
85
85
|
File.open(File.join(@output_dir, "insert-#{insert_idx}-#{table_name}.#{adapter.output_extension}"), 'w') do |file|
|
|
86
|
+
pre = adapter.pre_insert_sql(table)
|
|
87
|
+
file.puts(pre) if pre
|
|
86
88
|
file.puts(copy_sql)
|
|
87
89
|
post = adapter.post_insert_sql(table)
|
|
88
90
|
file.puts(post) if post
|
|
@@ -96,6 +98,8 @@ module Exwiw
|
|
|
96
98
|
|
|
97
99
|
@logger.info(" Generated INSERT statement for #{record_num} records (#{chunks.size} statement(s)).")
|
|
98
100
|
File.open(File.join(@output_dir, "insert-#{insert_idx}-#{table_name}.#{adapter.output_extension}"), 'w') do |file|
|
|
101
|
+
pre = adapter.pre_insert_sql(table)
|
|
102
|
+
file.puts(pre) if pre
|
|
99
103
|
file.puts(insert_sql)
|
|
100
104
|
post = adapter.post_insert_sql(table)
|
|
101
105
|
file.puts(post) if post
|
data/lib/exwiw/version.rb
CHANGED