Class: Clickwrap::Generators::UpgradeGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/clickwrap/upgrade_generator.rb

Overview

rails generate clickwrap:upgrade — the schema changes a newer release needs, as NEW migrations.

This generator exists because of a promise: a released migration is never edited underneath an installed application. Editing one would change the schema that existing evidence was written under while leaving that evidence in place, and a receipt whose table no longer means what it meant is worth less than no receipt at all. So upgrades add migrations, and the files you already ran stay exactly as they were.

At 0.1.0 there is nothing to upgrade from. This generator says so and creates nothing, rather than writing an empty migration to look busy.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dir) ⇒ Object



26
27
28
# File 'lib/generators/clickwrap/upgrade_generator.rb', line 26

def self.next_migration_number(dir)
  ActiveRecord::Generators::Base.next_migration_number(dir)
end

Instance Method Details

#create_upgrade_migrationsObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/clickwrap/upgrade_generator.rb', line 30

def create_upgrade_migrations
  say "\nā˜‘ļø  clickwrap #{Clickwrap::VERSION} has no upgrade migrations.", :green
  say "\n0.1.0 is the first release, so there is no earlier schema to move from and"
  say "nothing was created."
  say "\nIf you are installing clickwrap for the first time, you want:"
  say "    bin/rails generate clickwrap:install"
  say "\nWhen a later release needs a schema change, this generator will add NEW"
  say "migrations for it and report exactly what they do. Your existing migration"
  say "files stay untouched, and evidence written under them goes on verifying —"
  say "every released receipt format keeps a golden fixture, and a new format means"
  say "a new explicit schema and verifier rather than a quiet reinterpretation.\n"
end