diff options
| -rw-r--r-- | db/migrate/20160928084508_create_line_referential_sync_messages.rb | 11 | ||||
| -rw-r--r-- | lib/tasks/extensions.rake | 15 | 
2 files changed, 24 insertions, 2 deletions
| diff --git a/db/migrate/20160928084508_create_line_referential_sync_messages.rb b/db/migrate/20160928084508_create_line_referential_sync_messages.rb index dfd673ab6..75ab6fb78 100644 --- a/db/migrate/20160928084508_create_line_referential_sync_messages.rb +++ b/db/migrate/20160928084508_create_line_referential_sync_messages.rb @@ -1,13 +1,20 @@  class CreateLineReferentialSyncMessages < ActiveRecord::Migration -  def change +  def self.up +    execute 'CREATE EXTENSION IF NOT EXISTS hstore SCHEMA shared_extensions;' +      create_table :line_referential_sync_messages do |t|        t.integer :criticity        t.string :message_key        t.hstore :message_attributs        t.references :line_referential_sync -        t.timestamps      end +      add_index :line_referential_sync_messages, :line_referential_sync_id, name: 'line_referential_sync_id'    end + +  def self.down +    execute 'DROP EXTENSION IF EXISTS hstore SCHEMA shared_extensions;' +    drop_table :line_referential_sync_messages +  end  end diff --git a/lib/tasks/extensions.rake b/lib/tasks/extensions.rake new file mode 100644 index 000000000..6ede62b10 --- /dev/null +++ b/lib/tasks/extensions.rake @@ -0,0 +1,15 @@ +namespace :db do +  desc 'Creates shared_extensions Schema and enables hstore extension' +  task :extensions => :environment  do +    ActiveRecord::Base.connection.execute 'CREATE SCHEMA IF NOT EXISTS shared_extensions;' +    ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS hstore SCHEMA shared_extensions;' +  end +end + +Rake::Task["db:create"].enhance do +  Rake::Task["db:extensions"].invoke +end + +Rake::Task["db:test:purge"].enhance do +  Rake::Task["db:extensions"].invoke +end | 
