migrations that fixes the bug with smart annotations [fixes SCI-2426]

This commit is contained in:
zmagod 2018-05-18 13:57:52 +02:00
parent c3d247faae
commit b8098093ee
3 changed files with 11 additions and 4 deletions

View file

@ -7,8 +7,8 @@ class Repository < ApplicationRecord
foreign_key: :created_by_id,
class_name: 'User',
optional: true
has_many :repository_columns
has_many :repository_rows
has_many :repository_columns, dependent: :destroy
has_many :repository_rows, dependent: :destroy
has_many :repository_table_states,
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)
where('repositories.name ILIKE ?', "%#{query}%")
end
def importable_repository_fields
fields = {}
# 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.
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
enable_extension "plpgsql"