Module: HighLevel::Storage::ActiveRecord::Migration

Defined in:
lib/high_level/storage/active_record.rb

Overview

‘bin/rails g migration AddGohighlevelSessions` and paste the `change` block below — or call `Migration.create_table!(connection)` at boot in non-Rails apps.

Class Method Summary collapse

Class Method Details

.create_table!(connection = ::ActiveRecord::Base.connection) ⇒ void

This method returns an undefined value.

Create the gohighlevel_sessions table if it does not exist.

Parameters:

  • connection (ActiveRecord::ConnectionAdapters::AbstractAdapter) (defaults to: ::ActiveRecord::Base.connection)


36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/high_level/storage/active_record.rb', line 36

def create_table!(connection = ::ActiveRecord::Base.connection)
  return if connection.table_exists?(TABLE_NAME)

  connection.create_table(TABLE_NAME) do |t|
    t.string :application_id, null: false
    t.string :resource_id, null: false
    t.text :payload, null: false
    t.datetime :expire_at
    t.timestamps
  end
  connection.add_index TABLE_NAME, %i[application_id resource_id], unique: true
end