Module: ErrorLog::Migrations

Defined in:
lib/error_log/migrations.rb,
lib/error_log/migrations/base.rb,
lib/error_log/migrations/add_params_column.rb,
lib/error_log/migrations/add_vcs_revision_column.rb

Defined Under Namespace

Classes: AddParamsColumn, AddVcsRevisionColumn, Base

Class Method Summary collapse

Class Method Details

.auto_migrate!Object

Chack what do we have in database and migratie what’s needed Those migrations does not work like rails migrations, I check manually if table exists, or if given column exist, and add it if it’s not there. I didnt want to use rails migrations to avoid messing with your database, and adding there anything more than the error_logs table that is needed. Also this way we dont have to care if you still use old kind of numbered migrations.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/error_log/migrations.rb', line 10

def self.auto_migrate!

  unless Model.table_exists? 
     Base.up
     Model.reset_column_information
  end

  unless Model.column_names.include?('params')
     AddParamsColumn.up
     Model.reset_column_information
  end

  unless Model.column_names.include?('vcs_revision')
     AddVcsRevisionColumn.up
     Model.reset_column_information
  end

end