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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf3c1130520f3f918f80f213d1fc0bee1416c677d97ae3e9fe076538bd20bb92
4
- data.tar.gz: 9dd97924ac70c9b76d151c1fead90902a10900da36186e4ab7439aacaec94dbd
3
+ metadata.gz: '028047197ff7f7e93fdda9b7ca4ad934da9ac904c53bc7859da113f89710de23'
4
+ data.tar.gz: 2e7ef72dd106f3133ab6ba35b752c5c961fb02da02b98ede71400285fc36a2e5
5
5
  SHA512:
6
- metadata.gz: 45e71e45d5978ca9336b138a274759acecd1d0e50eb25826015269fb25238185642281002812e03f6f861e0c82d34b6c7d35fbf632f2d2a4ac67e9d376821dd4
7
- data.tar.gz: 3f2e7e35e5ed34704b6be40190a4a2f435d14078602fb22f6bfaec7f8f8655b3cdbf3838927d0c995a38dc526e9a0b31432f8aefa85ebcb20856a1bb5655b091
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.write(idempotent)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Exwiw
4
- VERSION = "0.4.3"
4
+ VERSION = "0.4.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exwiw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shia