Moved table changes to base migration.

This commit is contained in:
Martin Edenhofer 2012-12-27 10:41:02 +01:00
parent f1a7461e6e
commit 3bf33eb891
2 changed files with 29 additions and 46 deletions

View file

@ -31,22 +31,29 @@ class CreateTicket < ActiveRecord::Migration
add_index :ticket_priorities, [:name], :unique => true add_index :ticket_priorities, [:name], :unique => true
create_table :tickets do |t| create_table :tickets do |t|
t.references :group, :null => false t.references :group, :null => false
t.references :ticket_priority, :null => false t.references :ticket_priority, :null => false
t.references :ticket_state, :null => false t.references :ticket_state, :null => false
t.references :organization, :null => true t.references :organization, :null => true
t.column :number, :string, :limit => 60, :null => false t.column :number, :string, :limit => 60, :null => false
t.column :title, :string, :limit => 250, :null => false t.column :title, :string, :limit => 250,:null => false
t.column :owner_id, :integer, :null => false t.column :owner_id, :integer, :null => false
t.column :customer_id, :integer, :null => false t.column :customer_id, :integer, :null => false
t.column :note, :string, :limit => 250, :null => true t.column :note, :string, :limit => 250,:null => true
t.column :first_response, :timestamp, :null => true t.column :first_response, :timestamp, :null => true
t.column :last_contact, :timestamp, :null => true t.column :first_response_escal_date, :timestamp, :null => true
t.column :last_contact_agent, :timestamp, :null => true t.column :first_response_sla_time, :timestamp, :null => true
t.column :last_contact_customer, :timestamp, :null => true t.column :close_time, :timestamp, :null => true
t.column :close_time, :timestamp, :null => true t.column :close_time_escal_date, :timestamp, :null => true
t.column :updated_by_id, :integer, :null => false t.column :close_time_sla_time, :timestamp, :null => true
t.column :created_by_id, :integer, :null => false t.column :last_contact, :timestamp, :null => true
t.column :last_contact_agent, :timestamp, :null => true
t.column :last_contact_customer, :timestamp, :null => true
t.column :create_article_type_id, :integer, :null => true
t.column :create_article_sender_id, :integer, :null => true
t.column :article_count, :integer, :null => true
t.column :updated_by_id, :integer, :null => false
t.column :created_by_id, :integer, :null => false
t.timestamps t.timestamps
end end
add_index :tickets, [:ticket_state_id] add_index :tickets, [:ticket_state_id]
@ -58,10 +65,14 @@ class CreateTicket < ActiveRecord::Migration
add_index :tickets, [:title] add_index :tickets, [:title]
add_index :tickets, [:created_at] add_index :tickets, [:created_at]
add_index :tickets, [:first_response] add_index :tickets, [:first_response]
add_index :tickets, [:first_response_escal_date]
add_index :tickets, [:close_time]
add_index :tickets, [:close_time_escal_date]
add_index :tickets, [:last_contact] add_index :tickets, [:last_contact]
add_index :tickets, [:last_contact_agent] add_index :tickets, [:last_contact_agent]
add_index :tickets, [:last_contact_customer] add_index :tickets, [:last_contact_customer]
add_index :tickets, [:close_time] add_index :tickets, [:create_article_type_id]
add_index :tickets, [:create_article_sender_id]
add_index :tickets, [:created_by_id] add_index :tickets, [:created_by_id]
create_table :ticket_flags do |t| create_table :ticket_flags do |t|
@ -122,7 +133,7 @@ class CreateTicket < ActiveRecord::Migration
t.column :references, :string, :limit => 3200, :null => true t.column :references, :string, :limit => 3200, :null => true
t.column :body, :text, :null => true t.column :body, :text, :null => true
t.column :internal, :boolean, :null => false, :default => false t.column :internal, :boolean, :null => false, :default => false
t.column :updated_by_id, :integer, :null => false t.column :updated_by_id, :integer, :null => false
t.column :created_by_id, :integer, :null => false t.column :created_by_id, :integer, :null => false
t.timestamps t.timestamps
end end

View file

@ -1,28 +0,0 @@
class TicketExtend < ActiveRecord::Migration
def up
change_table :tickets do |t|
t.column :first_response_escal_date, :timestamp, :null => true
t.column :first_response_sla_time, :timestamp, :null => true
t.column :close_time_escal_date, :timestamp, :null => true
t.column :close_time_sla_time, :timestamp, :null => true
t.column :create_article_type_id, :integer, :null => true
t.column :create_article_sender_id, :integer, :null => true
t.column :article_count, :integer, :null => true
end
add_index :tickets, [:first_response_escal_date]
add_index :tickets, [:close_time_escal_date]
add_index :tickets, [:create_article_type_id]
add_index :tickets, [:create_article_sender_id]
tickets = Ticket.all
tickets.each {|t|
t.article_count = t.articles.count
t.create_article_type_id = t.articles.first.ticket_article_type.id
t.create_article_sender_id = t.articles.first.ticket_article_sender.id
t.save
}
end
def down
end
end