better_structure_sql 0.2.1 → 0.2.2
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: ef64a880cabbca1d370188561e604a27ecc2e8bd1040b68b123f9cf281b462ee
|
|
4
|
+
data.tar.gz: c4d5d2e7e366a0f768a8bc2933453958b10f46e72d5f168ea45af91d5b05473b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1d70b3713af668a419e7c9c5fcd66f516b36a50ec31e94b174b893207a7f2017e6ec273942345f191aa8860ab3f517d678eec04d62a32f25d36752c8a89a1b20
|
|
7
|
+
data.tar.gz: 39fcdb892436045a1579eeea41398fcf8ceb4b28407a192885d4aece4881b170e75724534b6cab30d7f0b58826aa1f5d03a7378f592cbf8d54f248ac98b080df
|
data/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
13
13
|
|
|
14
14
|
### Fixed
|
|
15
15
|
|
|
16
|
+
## [0.2.2] - 2025-11-23
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- Web UI now properly displays multi-file schema content for files under 1MB
|
|
20
|
+
- Optimized schema version show page to avoid loading ZIP archives unnecessarily
|
|
21
|
+
- Improved memory efficiency by explicitly selecting only needed columns
|
|
22
|
+
- Better error messages distinguishing "too large" from "not available" content
|
|
23
|
+
|
|
16
24
|
## [0.2.1] - 2025-11-20
|
|
17
25
|
|
|
18
26
|
### Changed
|
data/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
19
|
-
> **⚠️ Beta Notice**: Version 0.2.
|
|
19
|
+
> **⚠️ Beta Notice**: Version 0.2.2 is feature-complete and production-ready for **PostgreSQL**. Multi-database support (MySQL, SQLite) is implemented but considered experimental. APIs are stable but may see minor refinements before v1.0. We welcome feedback and contributions!
|
|
20
20
|
|
|
21
21
|
## ✨ Why BetterStructureSql?
|
|
22
22
|
|
|
@@ -41,20 +41,26 @@ module BetterStructureSql
|
|
|
41
41
|
# @raise [ActiveRecord::RecordNotFound] if schema version not found
|
|
42
42
|
# GET /better_structure_sql/schema_versions/:id
|
|
43
43
|
def show
|
|
44
|
-
# Load metadata first
|
|
44
|
+
# Load metadata first (no content or ZIP to minimize memory usage)
|
|
45
45
|
@schema_version = SchemaVersion
|
|
46
46
|
.select(:id, :pg_version, :format_type, :output_mode, :created_at,
|
|
47
47
|
:content_size, :line_count, :file_count, :content_hash)
|
|
48
48
|
.find(params[:id])
|
|
49
49
|
|
|
50
|
-
# Only load content for small
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
# Only load content for small files to display inline
|
|
51
|
+
# For large files, metadata is sufficient
|
|
52
|
+
if @schema_version.content_size <= MAX_DISPLAY_SIZE
|
|
53
|
+
# Reload full record with content column
|
|
54
|
+
# Note: We don't select zip_archive to avoid loading large binary data
|
|
55
|
+
@schema_version = SchemaVersion.select(
|
|
56
|
+
:id, :pg_version, :format_type, :output_mode, :created_at,
|
|
57
|
+
:content_size, :line_count, :file_count, :content_hash, :content
|
|
58
|
+
).find(params[:id])
|
|
57
59
|
end
|
|
60
|
+
|
|
61
|
+
# NOTE: Manifest extraction intentionally skipped to avoid loading
|
|
62
|
+
# potentially large ZIP archives into memory. Manifest is primarily
|
|
63
|
+
# useful for tooling and can be extracted from the download if needed.
|
|
58
64
|
rescue ActiveRecord::RecordNotFound
|
|
59
65
|
render plain: 'Schema version not found', status: :not_found
|
|
60
66
|
end
|
|
@@ -177,37 +183,6 @@ module BetterStructureSql
|
|
|
177
183
|
end
|
|
178
184
|
end
|
|
179
185
|
|
|
180
|
-
# Extracts embedded manifest JSON from multi-file schema content
|
|
181
|
-
#
|
|
182
|
-
# Manifest is stored between MANIFEST_JSON_START and MANIFEST_JSON_END markers
|
|
183
|
-
# as SQL comments. Parses and returns the manifest hash.
|
|
184
|
-
#
|
|
185
|
-
# @param content [String] the schema content containing embedded manifest
|
|
186
|
-
# @return [Hash, nil] parsed manifest hash or nil if not found/invalid
|
|
187
|
-
def extract_manifest_from_content(content)
|
|
188
|
-
# Manifest is embedded in content between MANIFEST_JSON_START and MANIFEST_JSON_END markers
|
|
189
|
-
return nil unless content.include?('MANIFEST_JSON_START')
|
|
190
|
-
|
|
191
|
-
# Extract JSON from between markers, removing comment prefixes
|
|
192
|
-
start_marker = '-- MANIFEST_JSON_START'
|
|
193
|
-
end_marker = '-- MANIFEST_JSON_END'
|
|
194
|
-
|
|
195
|
-
start_pos = content.index(start_marker)
|
|
196
|
-
end_pos = content.index(end_marker)
|
|
197
|
-
|
|
198
|
-
return nil unless start_pos && end_pos
|
|
199
|
-
|
|
200
|
-
manifest_section = content[(start_pos + start_marker.length)..(end_pos - 1)]
|
|
201
|
-
manifest_json = manifest_section.lines
|
|
202
|
-
.map { |line| line.sub(/^--\s?/, '') }
|
|
203
|
-
.join
|
|
204
|
-
|
|
205
|
-
JSON.parse(manifest_json)
|
|
206
|
-
rescue JSON::ParserError => e
|
|
207
|
-
Rails.logger.debug { "Failed to parse manifest: #{e.message}" }
|
|
208
|
-
nil
|
|
209
|
-
end
|
|
210
|
-
|
|
211
186
|
# Streams large file content from database in chunks
|
|
212
187
|
#
|
|
213
188
|
# Sets appropriate headers for streaming downloads and disables proxy buffering.
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
Download File
|
|
122
122
|
<% end %>
|
|
123
123
|
</a>
|
|
124
|
-
<% if @schema_version.
|
|
124
|
+
<% if @schema_version.content.present? %>
|
|
125
125
|
<button type="button" class="btn btn-outline-secondary btn-lg" onclick="copyToClipboard()">
|
|
126
126
|
<i class="bi bi-clipboard"></i>
|
|
127
127
|
Copy to Clipboard
|
|
@@ -130,19 +130,16 @@
|
|
|
130
130
|
</div>
|
|
131
131
|
|
|
132
132
|
<!-- Multi-file Info -->
|
|
133
|
-
<% if @schema_version.multi_file?
|
|
133
|
+
<% if @schema_version.multi_file? %>
|
|
134
134
|
<div class="alert alert-info mb-4">
|
|
135
135
|
<h6 class="alert-heading">
|
|
136
136
|
<i class="bi bi-info-circle"></i>
|
|
137
137
|
Multi-File Schema
|
|
138
138
|
</h6>
|
|
139
|
-
<p class="mb-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
<%= @manifest['directories'].keys.sort.join(', ') %>
|
|
144
|
-
</p>
|
|
145
|
-
<% end %>
|
|
139
|
+
<p class="mb-0">
|
|
140
|
+
This schema was generated in multi-file format with <%= @schema_version.file_count %> files across organized directories.
|
|
141
|
+
Download the ZIP archive to explore the directory structure and individual files.
|
|
142
|
+
</p>
|
|
146
143
|
</div>
|
|
147
144
|
<% end %>
|
|
148
145
|
|
|
@@ -158,14 +155,18 @@
|
|
|
158
155
|
</h5>
|
|
159
156
|
</div>
|
|
160
157
|
<div class="card-body p-0">
|
|
161
|
-
<% if @schema_version.
|
|
158
|
+
<% if @schema_version.content.present? %>
|
|
162
159
|
<pre class="code-block m-0" id="schema-content"><%= @schema_version.content %></pre>
|
|
163
160
|
<% else %>
|
|
164
161
|
<div class="alert alert-warning m-3">
|
|
165
162
|
<i class="bi bi-exclamation-triangle"></i>
|
|
166
|
-
<strong>
|
|
163
|
+
<strong>Content not loaded</strong>
|
|
167
164
|
<p class="mb-0 mt-2">
|
|
168
|
-
|
|
165
|
+
<% if @schema_version.content_size && @schema_version.content_size > 1048576 %>
|
|
166
|
+
This schema file is too large to display in the browser (limit: 1 MB, actual size: <%= number_to_human_size(@schema_version.content_size) %>).
|
|
167
|
+
<% else %>
|
|
168
|
+
The schema content is not available for inline display.
|
|
169
|
+
<% end %>
|
|
169
170
|
Please use the "Download" button above to download and view it locally.
|
|
170
171
|
</p>
|
|
171
172
|
</div>
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: better_structure_sql
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- sebyx07
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: pg
|
|
@@ -294,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
294
294
|
- !ruby/object:Gem::Version
|
|
295
295
|
version: '0'
|
|
296
296
|
requirements: []
|
|
297
|
-
rubygems_version: 3.
|
|
297
|
+
rubygems_version: 3.7.2
|
|
298
298
|
specification_version: 4
|
|
299
299
|
summary: Clean database schema dumps for Rails (PostgreSQL, MySQL, SQLite) without
|
|
300
300
|
external tool dependencies
|