diff options
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20150327150017_add_import_data_to_project.rb | 5 | ||||
-rw-r--r-- | db/migrate/20150411000035_fix_identities.rb | 19 | ||||
-rw-r--r-- | db/migrate/20150413192223_add_public_email_to_users.rb | 5 |
3 files changed, 26 insertions, 3 deletions
diff --git a/db/migrate/20150327150017_add_import_data_to_project.rb b/db/migrate/20150327150017_add_import_data_to_project.rb new file mode 100644 index 00000000000..12c00339eec --- /dev/null +++ b/db/migrate/20150327150017_add_import_data_to_project.rb @@ -0,0 +1,5 @@ +class AddImportDataToProject < ActiveRecord::Migration + def change + add_column :projects, :import_data, :text + end +end diff --git a/db/migrate/20150411000035_fix_identities.rb b/db/migrate/20150411000035_fix_identities.rb index 8f11a96ab01..d9051f9fffd 100644 --- a/db/migrate/20150411000035_fix_identities.rb +++ b/db/migrate/20150411000035_fix_identities.rb @@ -17,13 +17,26 @@ class FixIdentities < ActiveRecord::Migration end # Delete duplicate identities - execute "DELETE FROM identities WHERE provider = 'ldap' AND user_id IN (SELECT user_id FROM identities WHERE provider = '#{new_provider}')" + # We use a sort of self-join to find rows in identities which match on + # user_id but where one has provider 'ldap'. We delete the duplicate row + # with provider 'ldap'. + delete_statement = '' + case adapter_name.downcase + when /^mysql/ + delete_statement << 'DELETE FROM id1 USING identities AS id1, identities AS id2' + when 'postgresql' + delete_statement << 'DELETE FROM identities AS id1 USING identities AS id2' + else + raise "Unknown DB adapter: #{adapter_name}" + end + delete_statement << " WHERE id1.user_id = id2.user_id AND id1.provider = 'ldap' AND id2.provider = '#{new_provider}'" + execute delete_statement # Update legacy identities - execute "UPDATE identities SET provider = '#{new_provider}' WHERE provider = 'ldap';" + execute "UPDATE identities SET provider = '#{new_provider}' WHERE provider = 'ldap'" if table_exists?('ldap_group_links') - execute "UPDATE ldap_group_links SET provider = '#{new_provider}' WHERE provider IS NULL OR provider = 'ldap';" + execute "UPDATE ldap_group_links SET provider = '#{new_provider}' WHERE provider IS NULL OR provider = 'ldap'" end end diff --git a/db/migrate/20150413192223_add_public_email_to_users.rb b/db/migrate/20150413192223_add_public_email_to_users.rb new file mode 100644 index 00000000000..700e9f343a6 --- /dev/null +++ b/db/migrate/20150413192223_add_public_email_to_users.rb @@ -0,0 +1,5 @@ +class AddPublicEmailToUsers < ActiveRecord::Migration + def change + add_column :users, :public_email, :string, default: "", null: false + end +end |