Sha256: c6d91acef14eb37f5cce3627911272b12373dd6dcde1d6a1b268586274177f89

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 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 :bcdd_result_event_logs do |t|
      t.string :root_name, null: false, index: true
      t.string :trace_id, index: true
      t.integer :version, null: false
      t.integer :duration, null: false, index: true
      t.json :ids, null: false, default: {}
      t.json :records, null: false, default: []

      t.timestamps
    end

    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

2 entries across 2 versions & 1 rubygems

Version Path
bcdd-result-1.1.0 examples/multiple_listeners/db/setup.rb
bcdd-result-1.0.0 examples/multiple_listeners/db/setup.rb