Files
flagship/db/migrate/20250611160914_create_organizations.rb

22 lines
602 B
Ruby

class CreateOrganizations < ActiveRecord::Migration[8.0]
def change
# Enable pgcrypto extension for UUID support
enable_extension 'pgcrypto' if connection.adapter_name == 'PostgreSQL'
create_table :organizations, id: :uuid do |t|
t.string :name
t.string :subdomain
t.string :email_domain
t.string :logo_url
t.string :address
t.string :website
t.string :phone_number
t.timestamps
end
add_index :organizations, :subdomain, unique: true
add_reference :users, :organization, null: false, foreign_key: true, type: :uuid
end
end