Take models back out of migration, will have to fix it for postgres again later
This commit is contained in:
parent
fdb6675f28
commit
8d3f4609a3
2 changed files with 9 additions and 5 deletions
|
|
@ -56,6 +56,10 @@ SQL
|
|||
SQL
|
||||
end
|
||||
|
||||
def pv_count
|
||||
@pv_count ||= execute('SELECT count(*) FROM post_visibilities').to_a.first.first
|
||||
end
|
||||
|
||||
def self.up
|
||||
create_table :aspect_visibilities do |t|
|
||||
t.integer :post_id, :null => false
|
||||
|
|
@ -68,14 +72,14 @@ SQL
|
|||
add_foreign_key :aspect_visibilities, :aspects, :dependent => :delete
|
||||
add_foreign_key :aspect_visibilities, :posts, :dependent => :delete
|
||||
|
||||
delete_disconnected_pvs if PostVisibility.count > 0
|
||||
delete_disconnected_pvs if pv_count > 0
|
||||
|
||||
add_column :post_visibilities, :contact_id, :integer, :null => false
|
||||
|
||||
move_author_pvs_to_aspect_pvs if PostVisibility.count > 0
|
||||
set_pv_contact_ids if PostVisibility.count > 0
|
||||
move_author_pvs_to_aspect_pvs if pv_count > 0
|
||||
set_pv_contact_ids if pv_count > 0
|
||||
|
||||
delete_duplicate_pvs if PostVisibility.count > 0
|
||||
delete_duplicate_pvs if pv_count > 0
|
||||
|
||||
remove_index :post_visibilities, [:aspect_id, :post_id]
|
||||
remove_column :post_visibilities, :aspect_id
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ SQL
|
|||
SQL
|
||||
end
|
||||
def self.up
|
||||
if Message.count > 0
|
||||
if execute('SELECT COUNT(*) FROM messages').to_a.first.first > 0
|
||||
delete_disconnected_conversations
|
||||
delete_disconnected_messages
|
||||
delete_disconnected_cvs
|
||||
|
|
|
|||
Loading…
Reference in a new issue