Sha256: 387a08c0595812dc3c4de7671c598b410fd86493c0a413183f2c226640feef20

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

-*- indent-tabs-mode:nil; -*-

# DeclareSchema - Migration Generator

Our test requires to prepare the testapp:
{.hidden}

    doctest_require: 'prepare_testapp'

{.hidden}

And requires also that you enter the right choice when prompted. OK we're ready to get going.

## Alternate Primary Keys

### create
   doctest: create table with custom primary_key
   >>
    class Foo < ActiveRecord::Base
      fields do
      end
      self.primary_key="foo_id"
    end
   >> Rails::Generators.invoke 'declare_schema:migration', %w(-n -m)
   >> Foo.primary_key
   => 'foo_id'

### migrate from
   doctest: rename from custom primary_key
   >>
    class Foo < ActiveRecord::Base
      self.primary_key="id"
    end
    puts "\n\e[45m Please enter 'id' (no quotes) at the next prompt \e[0m"
   >> Rails::Generators.invoke 'declare_schema:migration', %w(-n -m)
   >> Foo.primary_key
   => 'id'

### migrate to

   doctest: rename to custom primary_key
   >>
    class Foo < ActiveRecord::Base
      self.primary_key="foo_id"
    end
    puts "\n\e[45m Please enter 'drop id' (no quotes) at the next prompt \e[0m"
   >> Rails::Generators.invoke 'declare_schema:migration', %w(-n -m)
   >> Foo.primary_key
   => 'foo_id'

### ensure it doesn't cause further migrations

   doctest: check no further migrations
   >> up, down = Generators::DeclareSchema::Migration::Migrator.run
   >> up
   => ""

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
declare_schema-0.1.3 test/interactive_primary_key.rdoctest
declare_schema-0.1.2 test/interactive_primary_key.rdoctest
declare_schema-0.1.1 test/interactive_primary_key.rdoctest
declare_schema-0.1.0 test/interactive_primary_key.rdoctest