Project

General

Profile

Feature #24013 » issue-24013-r16009-db-migrate.diff

Toshi MARUYAMA, 2016-11-28 14:13

View differences:

db/migrate/007_create_journals.rb
22 22
    end
23 23

  
24 24
    # indexes
25
    add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id"
25
    add_index "journals", ["journalized_id", "journalized_type"]
26 26
    add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
27 27

  
28 28
    Permission.create :controller => "issues", :action => "history", :description => "label_history", :sort => 1006, :is_public => true, :mail_option => 0, :mail_enabled => 0
db/migrate/107_add_open_id_authentication_tables.rb
1 1
class AddOpenIdAuthenticationTables < ActiveRecord::Migration
2 2
  def self.up
3
    create_table :open_id_authentication_associations, :force => true do |t|
3
    create_table :open_id_auth_associations, :force => true do |t|
4 4
      t.integer :issued, :lifetime
5 5
      t.string :handle, :assoc_type
6 6
      t.binary :server_url, :secret
7 7
    end
8 8

  
9
    create_table :open_id_authentication_nonces, :force => true do |t|
9
    create_table :open_id_auth_nonces, :force => true do |t|
10 10
      t.integer :timestamp, :null => false
11 11
      t.string :server_url, :null => true
12 12
      t.string :salt, :null => false
......
14 14
  end
15 15

  
16 16
  def self.down
17
    drop_table :open_id_authentication_associations
18
    drop_table :open_id_authentication_nonces
17
    drop_table :open_id_auth_associations
18
    drop_table :open_id_auth_nonces
19 19
  end
20 20
end
db/migrate/20130201184705_add_unique_index_on_tokens_value.rb
2 2
  def up
3 3
    say_with_time "Adding unique index on tokens, this may take some time..." do
4 4
      # Just in case
5
      duplicates = Token.connection.select_values("SELECT value FROM #{Token.table_name} GROUP BY value HAVING COUNT(id) > 1")
5
      duplicates = Token.group(:value).having('COUNT(id) > 1').select(:value).to_a
6 6
      Token.where(:value => duplicates).delete_all
7 7
  
8 8
      add_index :tokens, :value, :unique => true, :name => 'tokens_value'
db/migrate/20130215111141_populate_issues_closed_on.rb
10 10
        " AND #{Journal.table_name}.journalized_type = 'Issue' AND #{Journal.table_name}.journalized_id = #{Issue.table_name}.id" +
11 11
        " AND #{JournalDetail.table_name}.property = 'attr' AND #{JournalDetail.table_name}.prop_key = 'status_id'" +
12 12
        " AND #{JournalDetail.table_name}.old_value NOT IN (#{closed_status_values})" +
13
        " AND #{JournalDetail.table_name}.value IN (#{closed_status_values})"
13
        " AND #{JournalDetail.table_name}.#{'value'.quote_column_name} IN (#{closed_status_values})"
14 14
      Issue.update_all "closed_on = (#{subselect})"
15 15

  
16 16
      # Then set closed_on for closed issues that weren't up updated by the above UPDATE
(6-6/11)