Merge pull request #1150 from ZmagoD/zd_SCI_2426

migrations that fixes the bug with smart annotations [fixes SCI-2426]
This commit is contained in:
Zmago Devetak 2018-05-21 14:15:47 +02:00 committed by GitHub
commit 2ac04ee476
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View file

@ -7,8 +7,8 @@ class Repository < ApplicationRecord
foreign_key: :created_by_id, foreign_key: :created_by_id,
class_name: 'User', class_name: 'User',
optional: true optional: true
has_many :repository_columns has_many :repository_columns, dependent: :destroy
has_many :repository_rows has_many :repository_rows, dependent: :destroy
has_many :repository_table_states, has_many :repository_table_states,
inverse_of: :repository, dependent: :destroy inverse_of: :repository, dependent: :destroy
has_many :report_elements, inverse_of: :repository, dependent: :destroy has_many :report_elements, inverse_of: :repository, dependent: :destroy
@ -60,7 +60,7 @@ class Repository < ApplicationRecord
def self.name_like(query) def self.name_like(query)
where('repositories.name ILIKE ?', "%#{query}%") where('repositories.name ILIKE ?', "%#{query}%")
end end
def importable_repository_fields def importable_repository_fields
fields = {} fields = {}
# First and foremost add record name # First and foremost add record name

View file

@ -0,0 +1,7 @@
class RemoveRepositoryRowsAndColumnsWithoutRepository < ActiveRecord::Migration[5.1]
def up
repository_ids = Repository.select(:id)
RepositoryRow.where.not(repository_id: repository_ids).delete_all
RepositoryColumn.where.not(repository_id: repository_ids).delete_all
end
end

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180417062042) do ActiveRecord::Schema.define(version: 20180518113526) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"