Sha256: bf6f9a1b57f13335ef399f7f9bce8d70591bfe024866a4add7b5e061994d7611

Contents?: true

Size: 961 Bytes

Versions: 8

Compression:

Stored size: 961 Bytes

Contents

require "support/active_record"
require "json"

DB = Pathname.new("test.sqlite3")

class MyActiveRecordModel < ActiveRecord::Base
  has_many :my_active_record_model_transitions
end

class MyActiveRecordModelTransition < ActiveRecord::Base
  belongs_to :my_active_record_model
  serialize :metadata, JSON
end

class CreateMyActiveRecordModelMigration < ActiveRecord::Migration
  def change
    create_table :my_active_record_models do |t|
      t.string :current_state
      t.timestamps
    end
  end
end

# TODO: make this a module we can extend from the app? Or a generator?
class CreateMyActiveRecordModelTransitionMigration < ActiveRecord::Migration
  def change
    create_table :my_active_record_model_transitions do |t|
      t.string  :to_state
      t.integer :my_active_record_model_id
      t.integer :sort_key
      t.text    :metadata
      t.timestamps
    end

    add_index :my_active_record_model_transitions, :sort_key, unique: true
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
statesman-0.8.3 spec/support/active_record.rb
statesman-0.8.2 spec/support/active_record.rb
statesman-0.8.1 spec/support/active_record.rb
statesman-0.8.0 spec/support/active_record.rb
statesman-0.7.0 spec/support/active_record.rb
statesman-0.6.1 spec/support/active_record.rb
statesman-0.6.0 spec/support/active_record.rb
statesman-0.5.0 spec/support/active_record.rb