Skip to content

Commit 4d153f9

Browse files
Exclude system tables from SQLite schema dumps
1 parent 02621b9 commit 4d153f9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

activerecord/lib/active_record/tasks/sqlite_database_tasks.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def structure_dump(filename, extra_flags)
5050
if ignore_tables.any?
5151
ignore_tables = connection.data_sources.select { |table| ignore_tables.any? { |pattern| pattern === table } }
5252
condition = ignore_tables.map { |table| connection.quote(table) }.join(", ")
53-
args << "SELECT sql FROM sqlite_master WHERE tbl_name NOT IN (#{condition}) ORDER BY tbl_name, type DESC, name"
53+
args << "SELECT sql || ';' FROM sqlite_master WHERE tbl_name NOT IN (#{condition}) ORDER BY tbl_name, type DESC, name"
5454
else
55-
args << ".schema"
55+
args << ".schema --nosys"
5656
end
5757
run_cmd("sqlite3", args, filename)
5858
end

activerecord/test/cases/adapters/sqlite3/sqlite_rake_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def test_structure_dump_execution_fails
214214
assert_called_with(
215215
Kernel,
216216
:system,
217-
["sqlite3", "--noop", "db_create.sqlite3", ".schema"],
217+
["sqlite3", "--noop", "db_create.sqlite3", ".schema --nosys"],
218218
returns: nil,
219219
out: "awesome-file.sql"
220220
) do

0 commit comments

Comments
 (0)