Sha256: 2d894cfdaa5bbea59bb211e1dc0297300bf03b2c2d7b99a26b170662648fe3fc

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require "active_support/all"

ActiveRecord::Base.establish_connection(
  host: "localhost",
  adapter: "sqlite3",
  database: ":memory:"
)

ActiveRecord::Schema.define do
  suppress_messages do
    create_table :accounts do |t|
      t.string :uuid, null: false, index: {unique: true}

      t.timestamps
    end

    create_table :users do |t|
      t.string :uuid, null: false, index: {unique: true}
      t.string :name, null: false
      t.string :email, null: false, index: {unique: true}
      t.string :password_digest, null: false

      t.timestamps
    end

    create_table :user_tokens do |t|
      t.belongs_to :user, null: false, foreign_key: true, index: true
      t.string :access_token, null: false
      t.string :refresh_token, null: false
      t.datetime :access_token_expires_at, null: false
      t.datetime :refresh_token_expires_at, null: false

      t.timestamps
    end

    create_table :account_members do |t|
      t.integer :role, null: false, default: 0
      t.belongs_to :user, null: false, foreign_key: true, index: true
      t.belongs_to :account, null: false, foreign_key: true, index: true

      t.timestamps

      t.index %i[account_id role], unique: true, where: "(role = 0)"
      t.index %i[account_id user_id], unique: true
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solid-process-0.4.0 examples/business_processes/db/setup.rb
solid-process-0.3.0 examples/business_processes/db/setup.rb
solid-process-0.2.0 examples/business_processes/db/setup.rb
solid-process-0.1.0 examples/business_processes/db/setup.rb