Sha256: 7738f052142059bf6a53c152b3aa56581531c840a856691701aacd875242cda0
Contents?: true
Size: 1.3 KB
Versions: 4
Compression:
Stored size: 1.3 KB
Contents
require 'ardb' require 'ardb/adapter/base' class Ardb::Adapter class Postgresql < Base def public_schema_settings self.config_settings.merge({ :database => 'postgres', :schema_search_path => 'public' }) end def create_db ActiveRecord::Base.establish_connection(self.public_schema_settings) ActiveRecord::Base.connection.create_database(self.database, self.config_settings) ActiveRecord::Base.establish_connection(self.config_settings) end def drop_db ActiveRecord::Base.establish_connection(self.public_schema_settings) ActiveRecord::Base.connection.drop_database(self.database) end def drop_tables ActiveRecord::Base.connection.tap do |conn| tables = conn.execute "SELECT table_name"\ " FROM information_schema.tables"\ " WHERE table_schema = 'public';" tables.each{ |row| conn.execute "DROP TABLE #{row['table_name']} CASCADE" } end end def foreign_key_add_sql "ALTER TABLE :from_table"\ " ADD CONSTRAINT :name"\ " FOREIGN KEY (:from_column)"\ " REFERENCES :to_table (:to_column)" end def foreign_key_drop_sql "ALTER TABLE :from_table"\ " DROP CONSTRAINT :name" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ardb-0.4.0 | lib/ardb/adapter/postgresql.rb |
ardb-0.3.0 | lib/ardb/adapter/postgresql.rb |
ardb-0.2.0 | lib/ardb/adapter/postgresql.rb |
ardb-0.1.0 | lib/ardb/adapter/postgresql.rb |