Sha256: 914b934254ef34b0056f10f0cb0f4590b315fbfe56665101e7dc9f60986949ad

Contents?: true

Size: 754 Bytes

Versions: 2

Compression:

Stored size: 754 Bytes

Contents

class <%= migration_name %> < ActiveRecord::Migration
  def self.up
    case connection.adapter_name
    when 'MySQL'
      execute(<<-SQL)
        CREATE TABLE `<%= table_name %>` (
          `key`    VARBINARY(250) NOT NULL PRIMARY KEY,
          `value`  MEDIUMBLOB NOT NULL,
          `cas`    INT UNSIGNED NOT NULL,
          `expiry` INT
        ) ENGINE=InnoDB
      SQL

    else
      create_table :<%= table_name %>, :id => false do |t|
        t.string  :key,   :null => false, :limit => 250
        t.binary  :value, :null => false
        t.integer :cas,   :null => false
        t.integer :expiry
      end
      add_index :<%= table_name %>, :key, :unique => true
    end
  end

  def self.down
    drop_table :<%= table_name %>
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
memcache-client-activerecord-1.0.0 generators/cache_model/templates/migration.rb
memcache-client-activerecord-0.2.0 generators/cache_model/templates/migration.rb