Created
September 14, 2012 02:51
-
-
Save rurounijones/3719523 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
Apartment.configure do |config| | |
config.excluded_models = ['Company'] | |
config.persistent_schemas = ['hstore'] | |
config.database_names = lambda{ Company.select(:name).map(&:name) } | |
end |
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 CreateEmployees < ActiveRecord::Migration | |
def change | |
create_table :employees do |t| | |
t.integer :company_id | |
t.string :name | |
t.hstore :data | |
t.timestamps | |
end | |
end | |
end |
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 SetupHstore < ActiveRecord::Migration | |
def self.up | |
execute "CREATE SCHEMA hstore" | |
execute "CREATE EXTENSION IF NOT EXISTS hstore SCHEMA hstore" | |
end | |
def self.down | |
execute "DROP EXTENSION IF EXISTS hstore" | |
execute "DROP SCHEMA hstore" | |
end | |
end |
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
$ rake db:create | |
$ rake db:migrate --trace | |
** Invoke db:migrate (first_time) | |
** Invoke environment (first_time) | |
** Execute environment | |
** Invoke db:load_config (first_time) | |
** Execute db:load_config | |
** Execute db:migrate | |
== SetupHstore: migrating ==================================================== | |
-- execute("CREATE SCHEMA hstore") | |
-> 0.0008s | |
-- execute("CREATE EXTENSION IF NOT EXISTS hstore SCHEMA hstore") | |
WARNING: => is deprecated as an operator name | |
DETAIL: This name may be disallowed altogether in future versions of PostgreSQL. | |
-> 0.0209s | |
== SetupHstore: migrated (0.0220s) =========================================== | |
== CreateCompanies: migrating ================================================ | |
-- create_table(:companies) | |
NOTICE: CREATE TABLE will create implicit sequence "companies_id_seq" for serial column "companies.id" | |
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "companies_pkey" for table "companies" | |
-> 0.0715s | |
== CreateCompanies: migrated (0.0717s) ======================================= | |
== CreateEmployees: migrating ================================================ | |
-- create_table(:employees) | |
NOTICE: CREATE TABLE will create implicit sequence "employees_id_seq" for serial column "employees.id" | |
rake aborted! | |
An error has occurred, this and all later migrations canceled: | |
PG::Error: ERROR: type "hstore" does not exist | |
LINE 1: ...d" integer, "name" character varying(255), "data" hstore, "c... | |
^ | |
: CREATE TABLE "employees" ("id" serial primary key, "company_id" integer, "name" character varying(255), "data" hstore, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment