Answer the question
In order to leave comments, you need to log in
postgresql + apartment. Migrations issue, column "database" does not exist?
Added username column to User (devise)
class AddUsernameToUser < ActiveRecord::Migration
def change
add_column :users, :username, :string, null: false
add_index :users, :username, unique: true
end
end
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column "database" does not exist
LINE 1: SELECT database FROM "public"."users"
^
: SELECT database FROM "public"."users"
/Users/mihail/Documents/workspace/work/RailsApp/s4t/config/initializers/apartment.rb:26:in `block (2 levels) in <top (required)>'
PG::UndefinedColumn: ERROR: column "database" does not exist
LINE 1: SELECT database FROM "public"."users"
^
/Users/mihail/Documents/workspace/work/RailsApp/s4t/config/initializers/apartment.rb:26:in `block (2 levels) in <top (required)>'
Tasks: TOP => apartment:migrate
(See full trace by running task with --trace)
Answer the question
In order to leave comments, you need to log in
You have not fully configured apartment. In the config/initializers/apartment.rb file, on line 26, you need to specify an array of all available tenants, that is, subdomains in your case. Since you are storing them in the username column of the User model, this line should look like this:
config.tenant_names = lambda { User.pluck :username }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question