From 307a5d7e1babe1fb279701815bb0b684d046250a Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Wed, 29 Apr 2020 10:42:00 +0200 Subject: [PATCH] Improve code style in migration [SCI-4552] --- db/migrate/20200331183640_add_repository_snapshots.rb | 9 ++++++--- db/structure.sql | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/db/migrate/20200331183640_add_repository_snapshots.rb b/db/migrate/20200331183640_add_repository_snapshots.rb index 771e70131..2273279f7 100644 --- a/db/migrate/20200331183640_add_repository_snapshots.rb +++ b/db/migrate/20200331183640_add_repository_snapshots.rb @@ -2,10 +2,13 @@ class AddRepositorySnapshots < ActiveRecord::Migration[6.0] def up - add_column :repositories, :parent_id, :bigint, null: true - add_column :repositories, :status, :integer, null: true + change_table :repositories, bulk: true do |t| + t.string :type + t.bigint :parent_id, null: true + t.integer :status, null: true + end + add_reference :repositories, :my_module - add_column :repositories, :type, :string execute "UPDATE \"repositories\" SET \"type\" = 'Repository'" execute "UPDATE \"activities\" SET \"subject_type\" = 'RepositoryBase' WHERE \"subject_type\" = 'Repository'" diff --git a/db/structure.sql b/db/structure.sql index b29d33308..8758c90e6 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1100,10 +1100,10 @@ CREATE TABLE public.repositories ( updated_at timestamp without time zone, discarded_at timestamp without time zone, permission_level integer DEFAULT 0 NOT NULL, + type character varying, parent_id bigint, status integer, - my_module_id bigint, - type character varying + my_module_id bigint );