Created
August 19, 2018 22:46
-
-
Save jonathan-wheeler/db266d98c4d61ecd942e3cd466baefdc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DummyTables | |
def self.create_tables | |
100.times do |table_ref| | |
ActiveRecord::Schema.define do | |
create_table "table#{table_ref}" do |t| | |
t.integer :int_col | |
t.string :string_col | |
t.uuid :uuid_col | |
t.hstore :hstore_col | |
t.json :json_col | |
t.jsonb :jsonb_col | |
t.integer :int_array_col, array: true | |
t.string :string_array_col, array: true | |
t.timestamps | |
end | |
end | |
end | |
end | |
end | |
ActiveRecord::Base.connection.create_database(:single_tenant_test) | |
ActiveRecord::Base.connection.create_database(:large_multi_tenant_tenant_test) | |
ActiveRecord::Base.establish_connection(adapter: :postgresql, database: :single_tenant_test) | |
ActiveRecord::Base.connection.execute("create extension hstore;") | |
DummyTables.create_tables | |
ActiveRecord::Base.establish_connection(adapter: :postgresql, database: :large_multi_tenant_tenant_test) | |
ActiveRecord::Base.connection.execute("create extension hstore;") | |
1000.times do |schema_ref| | |
p "------------------------------------------------------" | |
p | |
p | |
p "Tada 🎉 Schema #{schema_ref}" | |
p | |
p | |
p "------------------------------------------------------" | |
ActiveRecord::Base.connection.execute("create schema dummy_schema#{schema_ref}") | |
ActiveRecord::Base.connection.schema_search_path = "dummy_schema#{schema_ref},public" | |
DummyTables.create_tables | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment