Ruby on rails 3 通过控制器Rails删除或删除模式Postgresql

Ruby on rails 3 通过控制器Rails删除或删除模式Postgresql,ruby-on-rails-3,activerecord,multi-tenant,rails-postgresql,Ruby On Rails 3,Activerecord,Multi Tenant,Rails Postgresql,我有带postgresql的多租户应用程序rails, 我想删除模式(模式名=子域)并删除模式上的或表 控制器上的基本代码,wk。 accounts\u controller.rb def destroy @account = Account.find(params[:id]) conn = ActiveRecord::Base.connection conn.execute("DROP SCHEMA "+@account.subdomain)

我有带postgresql的多租户应用程序rails, 我想删除模式(模式名=子域)并删除模式上的或表

控制器上的基本代码,wk。 accounts\u controller.rb

def destroy
        @account = Account.find(params[:id])
        conn = ActiveRecord::Base.connection
        conn.execute("DROP SCHEMA "+@account.subdomain)
    end
错误消息

ActiveRecord::StatementInvalid in AccountsController#destroy

PG::Error: ERROR:  cannot drop schema subdomain1 because other objects depend on it
DETAIL:  table articles depends on schema subdomain1
table gambarinfos depends on schema subdomain1
table pages depends on schema subdomain1
table redactor_assets depends on schema subdomain1
table schema_migrations depends on schema subdomain1
table usersekolahs depends on schema subdomain1
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
: DROP SCHEMA subdomain1
有什么想法吗

thx

问题已通过解决


将CASCADE添加到conn.execute(“DROP SCHEMA”++@account.subdomain+“CASCADE”)

我认为这篇文章非常有用。