Module: MultitenancyTools
- Defined in:
- lib/multitenancy_tools.rb,
lib/multitenancy_tools/errors.rb,
lib/multitenancy_tools/version.rb,
lib/multitenancy_tools/dump_cleaner.rb,
lib/multitenancy_tools/table_dumper.rb,
lib/multitenancy_tools/schema_dumper.rb,
lib/multitenancy_tools/dump/data_only.rb,
lib/multitenancy_tools/schema_creator.rb,
lib/multitenancy_tools/schema_migrator.rb,
lib/multitenancy_tools/schema_switcher.rb,
lib/multitenancy_tools/dump/schema_only.rb,
lib/multitenancy_tools/functions_dumper.rb,
lib/multitenancy_tools/schema_destroyer.rb,
lib/multitenancy_tools/extensions_dumper.rb
Defined Under Namespace
Modules: Dump Classes: DumpCleaner, ExtensionsDumper, FunctionsDumper, PgDumpError, SchemaCreator, SchemaDestroyer, SchemaDumper, SchemaMigrator, SchemaSwitcher, TableDumper
Constant Summary collapse
- VERSION =
'0.2.1'
Class Method Summary collapse
-
.create(name, sql_file, connection = ActiveRecord::Base.connection) ⇒ Object
Creates a new schema using the SQL file as template.
-
.destroy(name, connection = ActiveRecord::Base.connection) ⇒ Object
Drops the schema from the database.
-
.dump_extensions(file, connection = ActiveRecord::Base.connection, **args) ⇒ Object
Generates a SQL dump of all extensions enabled on the database.
-
.dump_schema(database, schema, file, **args) ⇒ Object
Generates a SQL dump of the schema.
-
.dump_table(database, schema, table, file, **args) ⇒ Object
Generates a SQL dump of the table.
-
.using(schema, connection = ActiveRecord::Base.connection) { ... } ⇒ Object
Uses the passed schema as the scope for all queries triggered by the block.
Class Method Details
.create(name, sql_file, connection = ActiveRecord::Base.connection) ⇒ Object
Creates a new schema using the SQL file as template. This SQL file can be generated by SchemaDumper.
24 25 26 |
# File 'lib/multitenancy_tools.rb', line 24 def self.create(name, sql_file, connection = ActiveRecord::Base.connection) SchemaCreator.new(name, connection).create_from_file(sql_file) end |
.destroy(name, connection = ActiveRecord::Base.connection) ⇒ Object
Drops the schema from the database.
33 34 35 |
# File 'lib/multitenancy_tools.rb', line 33 def self.destroy(name, connection = ActiveRecord::Base.connection) SchemaDestroyer.new(name, connection).destroy end |
.dump_extensions(file, connection = ActiveRecord::Base.connection, **args) ⇒ Object
Generates a SQL dump of all extensions enabled on the database.
73 74 75 |
# File 'lib/multitenancy_tools.rb', line 73 def self.dump_extensions(file, connection = ActiveRecord::Base.connection, **args) ExtensionsDumper.new(connection).dump_to(file, **args) end |
.dump_schema(database, schema, file, **args) ⇒ Object
Generates a SQL dump of the schema. Requires pg_dump.
53 54 55 |
# File 'lib/multitenancy_tools.rb', line 53 def self.dump_schema(database, schema, file, **args) SchemaDumper.new(database, schema).dump_to(file, **args) end |
.dump_table(database, schema, table, file, **args) ⇒ Object
Generates a SQL dump of the table. Requires pg_dump.
64 65 66 |
# File 'lib/multitenancy_tools.rb', line 64 def self.dump_table(database, schema, table, file, **args) TableDumper.new(database, schema, table).dump_to(file, **args) end |
.using(schema, connection = ActiveRecord::Base.connection) { ... } ⇒ Object
Uses the passed schema as the scope for all queries triggered by the block.
43 44 45 |
# File 'lib/multitenancy_tools.rb', line 43 def self.using(schema, connection = ActiveRecord::Base.connection, &block) SchemaSwitcher.new(schema, connection).run(&block) end |