Can I specify a SQL Server schema name in a Rails ActiveRecord migration?

The current convention I'm working on is to use SQL Server schemas such as namespaces (e.g. Company.Employees, Company.Branches, etc.). Can I get ActiveRecord migration to use anything other than the standard dbo schema in SQL Server?

+3
source share
1 answer

In your migration, specify the table names with the schema prefix for the create_table and drop_table calls.

create_table("Company.Employees") do |t|
  t.column :name, :string, :limit => 60
  # Other fields here
end

In the model, override the default table name using set_table_name.

class Employees < ActiveRecord::Base
  set_table_name "Company.Employees"
end

On the other hand

, rails, , , database.yml.

+7

Source: https://habr.com/ru/post/1742143/


All Articles