Sha256: 96da5028c5b73f761a0702f0fdcd57b0b42dc6e6fd7a4ea33c4c1468ece6b43b

Contents?: true

Size: 1.9 KB

Versions: 5

Compression:

Stored size: 1.9 KB

Contents

require 'db/derby'
require 'jdbc_common'

class DerbyMigrationTest < Test::Unit::TestCase
  
  class CreateDummies < ActiveRecord::Migration
    
    def self.up
      create_table :dummies, :force => true do |t|
        t.string :year, :default => "", :null => false
      end
      add_index :dummies, :year, :unique => true
    end

  end

  class ChangeColumn < ActiveRecord::Migration
    
    def self.up
      create_table :people, :id => false, :force => true do |t|
        t.string :id, :limit => 22, :null => false
        t.string :name, :null => false
      end
      change_column(:people, :name, :string, { :limit => 22 })
      execute("SELECT id FROM people WHERE id = 'some string'")
    end

    def self.down
    end

  end

  class CreateIndex < ActiveRecord::Migration
    def self.up
      create_table :people, :id => false, :force => true do |t|
        t.string :id, :limit => 22, :null => false
        t.string :first_name, :null => false
        t.string :last_name, :null => false
        t.string :nickname, :null => false
        t.string :long_name, :null => false
        t.string :very_long_name, :null => false
        t.string :extremely_long_name, :null => false
      end

      add_index(:people, [:first_name, :last_name, :nickname, :long_name, :very_long_name, :extremely_long_name], :unique => true)

      remove_index(:people, [:first_name, :last_name, :nickname, :long_name, :very_long_name, :extremely_long_name])
    end

    def self.down
    end

  end

  def self.shutdown
    ActiveRecord::Base.connection.execute("DROP TABLE dummies") rescue nil
    ActiveRecord::Base.connection.execute("DROP TABLE people") rescue nil
  end
  
  def test_create_table_column_quoting_vs_keywords
    CreateDummies.up
  end

  def test_migrate_change_column_for_non_standard_id
    ChangeColumn.up
    ChangeColumn.down
  end

  def test_migrate_create_index
    CreateIndex.up
    CreateIndex.down
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.2.9.1 test/derby_migration_test.rb
activerecord-jdbc-adapter-1.3.0.beta2 test/db/derby/migration_test.rb
activerecord-jdbc-adapter-1.3.0.beta1 test/db/derby/migration_test.rb
activerecord-jdbc-adapter-1.2.9 test/derby_migration_test.rb
activerecord-jdbc-adapter-1.2.8 test/derby_migration_test.rb