Method: ActiveRecord::Tasks::SQLiteDatabaseTasks#structure_dump

Defined in:
lib/active_record/tasks/sqlite_database_tasks.rb

#structure_dump(filename, extra_flags) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/active_record/tasks/sqlite_database_tasks.rb', line 45

def structure_dump(filename, extra_flags)
  args = []
  args.concat(Array(extra_flags)) if extra_flags
  args << db_config.database

  ignore_tables = ActiveRecord::SchemaDumper.ignore_tables
  if ignore_tables.any?
    condition = ignore_tables.map { |table| connection.quote(table) }.join(", ")
    args << "SELECT sql FROM sqlite_master WHERE tbl_name NOT IN (#{condition}) ORDER BY tbl_name, type DESC, name"
  else
    args << ".schema"
  end
  run_cmd("sqlite3", args, filename)
end