Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ group :test do
gem 'rspec-its'
gem 'rspec-rails', '~> 8.0.2'
gem 'rspec-wait'
gem 'rubocop', '~> 1.82.1'
gem 'rubocop', '~> 1.84.0'
gem 'rubocop-capybara'
gem 'rubocop-factory_bot'
gem 'rubocop-rails', '~> 2.34'
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,15 @@ GEM
activesupport (>= 3.0.0)
mustache (~> 1.0, >= 0.99.4)
rspec (~> 3.0)
rubocop (1.82.1)
rubocop (1.84.0)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.48.0, < 2.0)
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.49.0)
Expand Down Expand Up @@ -678,7 +678,7 @@ DEPENDENCIES
rspec-rails (~> 8.0.2)
rspec-wait
rspec_api_documentation (>= 6.1.0)
rubocop (~> 1.82.1)
rubocop (~> 1.84.0)
rubocop-capybara
rubocop-factory_bot
rubocop-rails (~> 2.34)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
end

if self.class.name.match?(/mysql/i)
run <<-SQL.squish
run <<~SQL.squish
UPDATE service_plans
SET unique_id =
(SELECT CONCAT(services.provider, '_', services.label, '_', service_plans.name)
FROM services
WHERE services.id = service_plans.service_id)
SQL
else
run <<-SQL.squish
run <<~SQL.squish
UPDATE service_plans
SET unique_id =
(SELECT (services.provider || '_' || services.label || '_' || service_plans.name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Sequel.migration do
up do
run <<-SQL.squish
run <<~SQL.squish
INSERT INTO organizations_users SELECT * FROM organizations_managers m
WHERE NOT EXISTS (SELECT * FROM organizations_users u WHERE u.user_id = m.user_id AND u.organization_id = m.organization_id)
SQL

run <<-SQL.squish
run <<~SQL.squish
INSERT INTO organizations_users SELECT * FROM organizations_billing_managers m
WHERE NOT EXISTS (SELECT * FROM organizations_users u WHERE u.user_id = m.user_id AND u.organization_id = m.organization_id)
SQL

run <<-SQL.squish
run <<~SQL.squish
INSERT INTO organizations_users SELECT * FROM organizations_auditors m
WHERE NOT EXISTS (SELECT * FROM organizations_users u WHERE u.user_id = m.user_id AND u.organization_id = m.organization_id)
SQL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Sequel.migration do
up do
run <<-SQL.squish
run <<~SQL.squish
INSERT INTO service_dashboard_clients (uaa_id, service_id_on_broker)
SELECT sso_client_id, unique_id
FROM services
Expand All @@ -15,7 +15,7 @@
alter_table :services do
add_column :sso_client_id, String, unique: true
end
run <<-SQL.squish
run <<~SQL.squish
UPDATE services
SET sso_client_id = (
SELECT service_dashboard_clients.uaa_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
alter_table :service_dashboard_clients do
add_column :service_broker_id, Integer
end
run <<-SQL.squish
run <<~SQL.squish
UPDATE service_dashboard_clients
SET service_broker_id = (
SELECT services.service_broker_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
end

down do
run <<-SQL.squish
run <<~SQL.squish
DELETE FROM service_dashboard_clients WHERE service_broker_id IS NULL
SQL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
up do
add_column :apps, :health_check_type, String, default: 'port'

run <<-SQL.squish
run <<~SQL.squish
UPDATE apps a1
SET health_check_type = 'none'
WHERE id NOT IN (
Expand Down
8 changes: 4 additions & 4 deletions db/migrations/20150113201824_fix_created_at_column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
up do
if self.class.name.match?(/mysql/i)
table_names.each do |table|
run <<-SQL.squish
ALTER TABLE #{table} MODIFY created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
run <<~SQL.squish
ALTER TABLE #{table} MODIFY created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
SQL
end
end
Expand All @@ -44,8 +44,8 @@
down do
if self.class.name.match?(/mysql/i)
table_names.each do |table|
run <<-SQL.squish
ALTER TABLE #{table} MODIFY created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
run <<~SQL.squish
ALTER TABLE #{table} MODIFY created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
SQL
end
end
Expand Down
6 changes: 3 additions & 3 deletions db/migrations/20160322184040_update_app_port.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Sequel.migration do
up do
run <<-SQL.squish
run <<~SQL.squish
UPDATE apps
SET ports = null
WHERE docker_image is not null
and diego = true
and ports = '[8080]'
SQL

run <<-SQL.squish
run <<~SQL.squish
UPDATE apps_routes
SET app_port = null
WHERE app_port = '8080'
Expand All @@ -19,7 +19,7 @@
end

down do
run <<-SQL.squish
run <<~SQL.squish
UPDATE apps
SET ports = '8080'
WHERE ports is null and diego = true and docker_image is null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Sequel.migration do
up do
if database_type == :postgres
run <<-SQL.squish
run <<~SQL.squish
ALTER TABLE events DROP COLUMN IF EXISTS space_id;
SQL
elsif dataset.db['select * from information_schema.columns where table_name = \'events\' and column_name = \'space_id\''].any?
Expand Down
42 changes: 21 additions & 21 deletions db/migrations/20160914165525_migrate_v2_app_data_to_v3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
####

transaction do
generate_stop_events_query = <<-SQL.squish
generate_stop_events_query = <<~SQL.squish
INSERT INTO app_usage_events
(guid, created_at, instance_count, memory_in_mb_per_instance, state, app_guid, app_name, space_guid, space_name, org_guid, buildpack_guid, buildpack_name, package_state, parent_app_name, parent_app_guid, process_type, task_guid, task_name, package_guid, previous_state, previous_package_state, previous_memory_in_mb_per_instance, previous_instance_count)
SELECT %s, now(), p.instances, p.memory, 'STOPPED', p.guid, p.name, s.guid, s.name, o.guid, d.buildpack_receipt_buildpack_guid, d.buildpack_receipt_buildpack, p.package_state, a.name, a.guid, p.type, NULL, NULL, pkg.guid, 'STARTED', p.package_state, p.memory, p.instances
Expand Down Expand Up @@ -174,30 +174,30 @@
####
## Fill in v3 apps table data
###
run <<-SQL.squish
run <<~SQL.squish
INSERT INTO apps (guid, name, salt, encrypted_environment_variables, created_at, updated_at, space_guid, desired_state)
SELECT p.guid, p.name, p.salt, p.encrypted_environment_json, p.created_at, p.updated_at, s.guid, p.state
FROM processes as p, spaces as s
WHERE p.space_id = s.id
ORDER BY p.id
SQL

run <<-SQL.squish
run <<~SQL.squish
UPDATE processes SET app_guid=guid
SQL

#####
## Create lifecycle data for buildpack apps
####

run <<-SQL.squish
run <<~SQL.squish
INSERT INTO buildpack_lifecycle_data (app_guid, stack)
SELECT processes.guid, stacks.name
FROM processes, stacks
WHERE docker_image is NULL AND stacks.id = processes.stack_id
SQL

run <<-SQL.squish
run <<~SQL.squish
UPDATE buildpack_lifecycle_data
SET
admin_buildpack_name=(
Expand All @@ -222,14 +222,14 @@
## Fill in packages data
####

run <<-SQL.squish
run <<~SQL.squish
INSERT INTO packages (guid, type, package_hash, state, error, app_guid)
SELECT guid, 'bits', package_hash, 'READY', NULL, guid
FROM processes
WHERE package_hash IS NOT NULL AND docker_image IS NULL
SQL

run <<-SQL.squish
run <<~SQL.squish
INSERT INTO packages (guid, type, state, error, app_guid, docker_image)
SELECT guid, 'docker', 'READY', NULL, guid, docker_image
FROM processes
Expand All @@ -242,7 +242,7 @@

# backfill any v2 droplets that do not exist due to lazy backfilling in v2 droplets. it is unlikely there are
# any of these, but possible in very old CF deployments
run <<-SQL.squish
run <<~SQL.squish
INSERT INTO droplets (guid, app_id, droplet_hash, detected_start_command)
SELECT processes.guid, processes.id, processes.droplet_hash, '' AS detected_start_command
FROM processes
Expand All @@ -253,19 +253,19 @@
# pruning will not delete from the blobstore

# prune orphaned droplets
run <<-SQL.squish
run <<~SQL.squish
DELETE FROM droplets WHERE NOT EXISTS (SELECT 1 FROM processes WHERE droplets.app_id = processes.id)
SQL

# prune additional droplets, each app will have only one droplet
postgres_prune_droplets_query = <<-SQL.squish
postgres_prune_droplets_query = <<~SQL.squish
DELETE FROM droplets
USING droplets as d
JOIN processes ON processes.id = d.app_id
WHERE droplets.id = d.id AND (processes.droplet_hash <> d.droplet_hash OR processes.droplet_hash IS NULL)
SQL

mysql_prune_droplets_query = <<-SQL.squish
mysql_prune_droplets_query = <<~SQL.squish
DELETE droplets FROM droplets
JOIN processes ON processes.id = droplets.app_id
WHERE processes.droplet_hash <> droplets.droplet_hash OR processes.droplet_hash IS NULL
Expand All @@ -274,21 +274,21 @@
if dbtype == 'mysql'
run mysql_prune_droplets_query

run <<-SQL.squish
run <<~SQL.squish
DELETE a FROM droplets a, droplets b
WHERE a.app_id=b.app_id AND a.id < b.id
SQL
elsif dbtype == 'postgres'
run postgres_prune_droplets_query

run <<-SQL.squish
run <<~SQL.squish
DELETE FROM droplets a USING droplets b
WHERE a.app_id = b.app_id AND a.id < b.id
SQL
end

# convert to v3 droplets
postgres_convert_to_v3_droplets_query = <<-SQL.squish
postgres_convert_to_v3_droplets_query = <<~SQL.squish
UPDATE droplets
SET
guid = v2_app.guid,
Expand All @@ -304,7 +304,7 @@
WHERE v2_app.id = droplets.app_id
SQL

mysql_convert_to_v3_droplets_query = <<-SQL.squish
mysql_convert_to_v3_droplets_query = <<~SQL.squish
UPDATE droplets
JOIN processes as v2_app
ON v2_app.id = droplets.app_id
Expand All @@ -327,22 +327,22 @@
end

# add lifecycle data to buildpack droplets
run <<-SQL.squish
run <<~SQL.squish
INSERT INTO buildpack_lifecycle_data (droplet_guid)
SELECT droplets.guid
FROM processes, droplets
WHERE processes.docker_image is NULL AND droplets.app_guid = processes.guid
SQL

# set current droplet on v3 app
postgres_set_current_droplet_query = <<-SQL.squish
postgres_set_current_droplet_query = <<~SQL.squish
UPDATE apps
SET droplet_guid = droplets.guid
FROM droplets
WHERE droplets.app_guid = apps.guid
SQL

mysql_set_current_droplet_query = <<-SQL.squish
mysql_set_current_droplet_query = <<~SQL.squish
UPDATE apps
JOIN droplets as current_droplet
ON apps.guid = current_droplet.app_guid
Expand Down Expand Up @@ -372,14 +372,14 @@
## Migrate route mappings
####

run <<-SQL.squish
run <<~SQL.squish
UPDATE apps_routes SET
app_guid = (SELECT processes.guid FROM processes WHERE processes.id=apps_routes.app_id),
route_guid = (SELECT routes.guid FROM routes WHERE routes.id=apps_routes.route_id),
process_type = 'web'
SQL

run <<-SQL.squish
run <<~SQL.squish
UPDATE apps_routes SET app_port=8080 WHERE app_port IS NULL AND EXISTS (SELECT 1 FROM processes WHERE processes.docker_image IS NULL AND processes.id = apps_routes.app_id)
SQL

Expand Down Expand Up @@ -411,7 +411,7 @@
self[:apps_routes].where(id: ids_to_remove).delete
end

run <<-SQL.squish
run <<~SQL.squish
UPDATE service_bindings SET
app_guid = (SELECT processes.guid FROM processes WHERE processes.id=service_bindings.app_id),
service_instance_guid = (SELECT service_instances.guid FROM service_instances WHERE service_instances.id=service_bindings.service_instance_id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def flush
ids << c[0]
end

@db[<<-SQL.squish, *@batched_commands.flatten, *ids].update
@db[<<~SQL.squish, *@batched_commands.flatten, *ids].update
UPDATE droplets
SET process_types = (CASE #{cases.join(' ')} ELSE process_types END)
WHERE id IN (#{id_place_holders.join(',')})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Sequel.migration do
up do
transaction do
run <<-SQL.squish
run <<~SQL.squish
UPDATE processes SET health_check_timeout=NULL WHERE health_check_timeout='0';
SQL
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
raise "Unsupported MySQL version #{server_version}, required >= #{MIN_SERVER_VERSION}" if server_version < MIN_SERVER_VERSION

if self.class.name.match?(/mysql/i)
run <<-SQL.squish
run <<~SQL.squish
ALTER TABLE asg_timestamps MODIFY last_update TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)
SQL
end
end

down do
if self.class.name.match?(/mysql/i)
run <<-SQL.squish
run <<~SQL.squish
ALTER TABLE asg_timestamps MODIFY last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
SQL
end
Expand Down