source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20171103163351_add_name_to_service_bindings.rb | Ruby | apache-2.0 | 203 | main | 232 | Sequel.migration do
change do
alter_table :service_bindings do
add_column :name, String, size: 255, null: true
add_unique_constraint %i[app_guid name], name: :unique_service_binding_app_guid_name
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20180220224558_add_missing_primary_keys.rb | Ruby | apache-2.0 | 203 | main | 355 | Sequel.migration do
change do
# This migration originally added primary keys to ten join tables.
# It was split into ten separate migrations to make these operations more atomic,
# and less likely to cause a deadlock during migration - as seen in
# [this issue](https://github.com/cloudfoundry/cloud_co... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20181015223531_create_app_labels.rb | Ruby | apache-2.0 | 203 | main | 470 | Sequel.migration do
change do
create_table(:app_labels) do
VCAP::Migration.common(self)
String :app_guid, size: 255
String :key_prefix, size: 253
String :key_name, size: 63
String :value, size: 63
foreign_key [:app_guid], :apps, key: :guid, name: :fk_app_labels_app_guid
... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20130718234910_add_bindable_to_services.rb | Ruby | apache-2.0 | 203 | main | 237 | Sequel.migration do
change do
alter_table(:services) do
add_column :bindable, TrueClass
end
from(:services).update(bindable: true)
alter_table(:services) do
set_column_not_null :bindable
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20150218192154_remove_space_guid_from_v3_packages.rb | Ruby | apache-2.0 | 203 | main | 224 | Sequel.migration do
up do
alter_table :packages do
drop_column :space_guid
end
end
down do
alter_table :packages do
add_column :space_guid, String
add_index :space_guid
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20200210103523_create_service_plan_metadata.rb | Ruby | apache-2.0 | 203 | main | 388 | Sequel.migration do
change do
create_table(:service_plan_labels) do
VCAP::Migration.common(self)
VCAP::Migration.labels_common(self, :service_plan_labels, :service_plans)
end
create_table(:service_plan_annotations) do
VCAP::Migration.common(self)
VCAP::Migration.annotations_common... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20191218000616_add_guid_and_timestamps_to_spaces_managers.rb | Ruby | apache-2.0 | 203 | main | 959 | Sequel.migration do
up do
unless self[:spaces_managers].columns.include?(:role_guid)
alter_table :spaces_managers do
add_column :role_guid, String, size: 255
add_column :created_at, :timestamp, null: false, default: Sequel::CURRENT_TIMESTAMP
add_column :updated_at, :timestamp, null: ... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20190116193201_create_process_metadata_tables.rb | Ruby | apache-2.0 | 203 | main | 360 | Sequel.migration do
change do
create_table(:process_annotations) do
VCAP::Migration.common(self)
VCAP::Migration.annotations_common(self, :process_annotations, :processes)
end
create_table(:process_labels) do
VCAP::Migration.common(self)
VCAP::Migration.labels_common(self, :proces... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20160504182904_increase_task_command_size.rb | Ruby | apache-2.0 | 203 | main | 213 | Sequel.migration do
up do
alter_table :tasks do
set_column_type :command, String, text: true
end
end
down do
alter_table :tasks do
set_column_type :command, String
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20141120182308_reprocess_diego_apps.rb | Ruby | apache-2.0 | 203 | main | 382 | Sequel.migration do
up do
self[:apps].filter(diego: true).each do |row|
self[:apps].filter(id: row[:id]).update(diego: diego?(row))
end
end
def diego?(row)
decrypted = VCAP::CloudController::Encryptor.decrypt(row[:encrypted_environment_json], row[:salt])
environment_json = Oj.load(decrypted... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20170522233826_remove_duplicate_route_mapping_entries.rb | Ruby | apache-2.0 | 203 | main | 520 | Sequel.migration do
change do
alter_table(:route_mappings) do
set_column_default(:app_port, -1)
end
route_mappings_ids_to_keep = self[:route_mappings].where(app_port: nil).group_by(:app_guid, :route_guid, :process_type).select(Sequel.function(:min, :id))
self[:route_mappings].exclude(id: route... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20190128183957_create_build_annotations_table.rb | Ruby | apache-2.0 | 203 | main | 201 | Sequel.migration do
change do
create_table(:build_annotations) do
VCAP::Migration.common(self)
VCAP::Migration.annotations_common(self, :build_annotations, :builds)
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20170721205940_add_missing_task_stopped_usage_events.rb | Ruby | apache-2.0 | 203 | main | 382 | require 'securerandom'
Sequel.migration do
change do
# This migration was emptied because it performed an n^2 operation against
# app_usage_events, a large table (millions of rows) using columns
# that are not indexed. This can lead to this migration taking dozens of days.
#
# A future migration ... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20130730000217_create_service_brokers_table.rb | Ruby | apache-2.0 | 203 | main | 318 | Sequel.migration do
change do
create_table :service_brokers do
VCAP::Migration.common(self, :sbrokers)
String :name, null: false
String :broker_url, null: false
String :token, null: false
index :name, unique: true
index :broker_url, unique: true
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20191204144101_create_service_broker_update_request_metadata_tables.rb | Ruby | apache-2.0 | 203 | main | 466 | Sequel.migration do
change do
create_table(:service_broker_update_request_labels) do
VCAP::Migration.common(self)
VCAP::Migration.labels_common(self, :sb_update_request_labels, :service_broker_update_requests)
end
create_table(:service_broker_update_request_annotations) do
VCAP::Migrati... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20170425173340_add_docker_credentials_to_packages.rb | Ruby | apache-2.0 | 203 | main | 210 | Sequel.migration do
change do
add_column :packages, :docker_username, String
add_column :packages, :docker_password_salt, String
add_column :packages, :encrypted_docker_password, String
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20130219194917_create_stacks_table.rb | Ruby | apache-2.0 | 203 | main | 478 | # Copyright (c) 2009-2013 VMware, Inc.
require 'securerandom'
Sequel.migration do
change do
create_table :stacks do
VCAP::Migration.common(self)
String :name, null: false, case_insenstive: true
String :description, null: false
index :name, unique: true
end
alter_table :apps do
... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20150910221617_drop_routes_service_instance_id_column.rb | Ruby | apache-2.0 | 203 | main | 368 | # This migration was not backwards-compatible and caused API outages during upgrade.
# It has been altered from its original form.
Sequel.migration do
up do
alter_table :routes do
drop_foreign_key [:service_instance_id]
end
end
down do
alter_table :routes do
add_foreign_key [:service_ins... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20130501224802_rename_crash_events_to_app_events.rb | Ruby | apache-2.0 | 203 | main | 621 | Sequel.migration do
change do
alter_table :crash_events do
drop_constraint :fk_crash_events_app_id, type: :foreign_key
add_foreign_key :app_id, :apps, name: :fk_app_events_app_id
drop_index :app_id
add_index :app_id, name: :app_events_app_id_index
drop_index :created_at
add_i... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20240529195136_add_task_guid_index_to_app_usage_events.rb | Ruby | apache-2.0 | 203 | main | 1,281 | Sequel.migration do
# adding an index concurrently cannot be done within a transaction
no_transaction
up do
if database_type == :postgres
VCAP::Migration.with_concurrent_timeout(self) do
add_index :app_usage_events, :task_guid, name: :app_usage_events_task_guid_index, if_not_exists: true, concu... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20171220183100_add_encryption_key_label_column_to_tables_with_encrypted_columns.rb | Ruby | apache-2.0 | 203 | main | 553 | Sequel.migration do
tables_to_alter = %i[
env_groups
service_brokers
service_bindings
service_instances
service_keys
apps
buildpack_lifecycle_buildpacks
buildpack_lifecycle_data
droplets
packages
tasks
]
up do
tables_to_alter.each do |table|
alter_table(table)... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20190716215540_add_status_indices_to_deployments.rb | Ruby | apache-2.0 | 203 | main | 222 | Sequel.migration do
change do
alter_table :deployments do
add_index :status_value, name: :deployments_status_value_index
add_index :status_reason, name: :deployments_status_reason_index
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20151016173751_create_buildpack_lifecycle_data.rb | Ruby | apache-2.0 | 203 | main | 1,468 | Sequel.migration do
up do
alter_table(:v3_droplets) do
drop_foreign_key [:app_guid]
end
alter_table(:packages) do
drop_foreign_key [:app_guid]
end
alter_table(:apps) do
drop_foreign_key [:app_guid]
drop_index :app_guid
end
alter_table(:apps_v3_routes) do
drop_... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20150124164257_add_organizations_private_domains.rb | Ruby | apache-2.0 | 203 | main | 436 | Sequel.migration do
change do
create_table :organizations_private_domains do
Integer :organization_id, null: false
foreign_key [:organization_id], :organizations, name: :fk_organization_id
Integer :private_domain_id, null: false
foreign_key [:private_domain_id], :domains, name: :fk_privat... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20201124153320_create_service_key_operations.rb | Ruby | apache-2.0 | 203 | main | 576 | Sequel.migration do
change do
create_table :service_key_operations do
VCAP::Migration.timestamps(self, :service_key_operations)
Integer :service_key_id
String :state, size: 255, null: false
String :type, size: 255, null: false
String :description, size: 10_000
String :broker_p... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20190916184059_create_revision_sidecars_table.rb | Ruby | apache-2.0 | 203 | main | 884 | Sequel.migration do
change do
create_table :revision_sidecars do
VCAP::Migration.common(self)
String :name, size: 255, null: false
String :command, size: 4096, null: false
String :revision_guid, size: 255, null: false
Integer :memory, default: nil
foreign_key [:revision_guid... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20191218000638_add_guid_and_timestamps_to_organizations_users.rb | Ruby | apache-2.0 | 203 | main | 995 | Sequel.migration do
up do
unless self[:organizations_users].columns.include?(:role_guid)
alter_table :organizations_users do
add_column :role_guid, String, size: 255
add_column :created_at, :timestamp, null: false, default: Sequel::CURRENT_TIMESTAMP
add_column :updated_at, :timestamp... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20251030100000_add_unique_constraint_to_sidecar_process_types.rb | Ruby | apache-2.0 | 203 | main | 2,658 | Sequel.migration do
up do
transaction do
# Clean up sidecar_process_types
duplicates = self[:sidecar_process_types].
select(:sidecar_guid, :type).
group(:sidecar_guid, :type).
having { count(1) > 1 }
duplicates.each do |dup|
pks_t... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20140609234412_add_running_default_to_app_security_groups.rb | Ruby | apache-2.0 | 203 | main | 231 | Sequel.migration do
change do
alter_table :app_security_groups do
add_column :running_default, FalseClass, default: false, required: true
add_index :running_default, name: 'asgs_running_default'
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20150306233007_increase_size_of_delayed_job_handler.rb | Ruby | apache-2.0 | 203 | main | 338 | Sequel.migration do
up do
if self.class.name.match?(/mysql/i)
alter_table :delayed_jobs do
set_column_type :handler, :longtext
end
end
end
down do
if self.class.name.match?(/mysql/i)
alter_table :delayed_jobs do
set_column_type :handler, String, text: true
end
... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20250225132929_add_apps_file_based_service_binding_feature_columns.rb | Ruby | apache-2.0 | 203 | main | 2,416 | Sequel.migration do
up do
if database_type == :postgres
alter_table :apps do
add_column :service_binding_k8s_enabled, :boolean, default: false, null: false, if_not_exists: true
add_column :file_based_vcap_services_enabled, :boolean, default: false, null: false, if_not_exists: true
u... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20181211230616_create_droplet_annotations_table.rb | Ruby | apache-2.0 | 203 | main | 207 | Sequel.migration do
change do
create_table(:droplet_annotations) do
VCAP::Migration.common(self)
VCAP::Migration.annotations_common(self, :droplet_annotations, :droplets)
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20151231224207_increase_security_group_rules_length.rb | Ruby | apache-2.0 | 203 | main | 346 | Sequel.migration do
up do
alter_table :security_groups do
if Sequel::Model.db.adapter_scheme == :postgres
set_column_type :rules, :text
else
set_column_type :rules, :mediumtext
end
end
end
down do
alter_table :security_groups do
set_column_type :rules, 'varchar... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20251028135214_route_bindings_unique_index.rb | Ruby | apache-2.0 | 203 | main | 1,997 | Sequel.migration do
up do
transaction do
# Remove duplicate entries if they exist
duplicates = self[:route_bindings].
select(:route_id, :service_instance_id).
group(:route_id, :service_instance_id).
having { count(:id) > 1 }
duplicates.ea... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20191031135500_create_service_broker_update_requests.rb | Ruby | apache-2.0 | 203 | main | 521 | Sequel.migration do
change do
create_table(:service_broker_update_requests) do
VCAP::Migration.common(self)
String :name, size: 255
String :broker_url, size: 255
String :authentication, size: 16_000
String :salt, size: 255
String :encryption_key_label, size: 255
Integer ... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20251016120006_security_groups_spaces_unique_index.rb | Ruby | apache-2.0 | 203 | main | 2,023 | Sequel.migration do
up do
transaction do
# Remove duplicate entries if they exist
duplicates = self[:security_groups_spaces].
select(:security_group_id, :space_id).
group(:security_group_id, :space_id).
having { count(:security_groups_spaces_pk)... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20180515221720_create_primary_key_for_spaces_auditors.rb | Ruby | apache-2.0 | 203 | main | 359 | require File.expand_path('../../helpers/change_primary_key', __FILE__)
Sequel.migration do
up do
add_primary_key_to_table(:spaces_auditors, :spaces_auditors_pk)
end
down do
remove_primary_key_from_table(:spaces_auditors,
:spaces_auditors_pkey,
... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20191112154745_drop_service_broker_states_table.rb | Ruby | apache-2.0 | 203 | main | 204 | Sequel.migration do
up do
# The endpoint that used this table has always been experimental
drop_table?(:service_broker_states)
end
down do
# This migration cannot be reversed
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20150625171651_change_stack_description_to_allow_null.rb | Ruby | apache-2.0 | 203 | main | 206 | Sequel.migration do
up do
alter_table(:stacks) do
set_column_allow_null :description
end
end
down do
alter_table(:stacks) do
set_column_not_null :description
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20150113201824_fix_created_at_column.rb | Ruby | apache-2.0 | 203 | main | 1,076 | Sequel.migration do
table_names = %w[
app_events
app_usage_events
apps
apps_v3
billing_events
buildpacks
delayed_jobs
domains
droplets
env_groups
events
feature_flags
organizations
quota_definitions
routes
security_groups
service_auth_tokens
serv... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20130611235653_drop_organizations_can_access_non_public_plans.rb | Ruby | apache-2.0 | 203 | main | 243 | Sequel.migration do
up do
drop_column :organizations, :can_access_non_public_plans
end
down do
alter_table :organizations do
add_column :can_access_non_public_plans, :boolean, default: false, null: false
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20140512175050_add_service_usage_event.rb | Ruby | apache-2.0 | 203 | main | 712 | Sequel.migration do
change do
create_table :service_usage_events do
primary_key :id
VCAP::Migration.guid(self, 'usage_events')
Timestamp :created_at, null: false
index :created_at, name: :created_at_index
String :state, null: false
String :org_guid, null: false
String :sp... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20130501002952_use_text_fields_for_service_credentials.rb | Ruby | apache-2.0 | 203 | main | 244 | Sequel.migration do
change do
alter_table :service_instances do
set_column_type :credentials, String, text: true
end
alter_table :service_bindings do
set_column_type :credentials, String, text: true
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20140130215438_change_services_provider_default.rb | Ruby | apache-2.0 | 203 | main | 673 | Sequel.migration do
up do
self[:services].filter(provider: nil).all.each do |service|
if self[:services].filter(label: service.label, provider: '').first
service.update(label: "#{service.label}-#{service.id}", provider: '')
else
service.update(provider: '')
end
end
alter... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20190617181159_add_key_prefix_to_revision_annotations.rb | Ruby | apache-2.0 | 203 | main | 223 | Sequel.migration do
change do
unless self[:revision_annotations].columns.include?(:key_prefix)
alter_table(:revision_annotations) do
add_column :key_prefix, String, size: 253
end
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20141216183550_add_health_check_type_to_apps.rb | Ruby | apache-2.0 | 203 | main | 482 | Sequel.migration do
up do
add_column :apps, :health_check_type, String, default: 'port'
run <<~SQL.squish
UPDATE apps a1
SET health_check_type = 'none'
WHERE id NOT IN (
SELECT id FROM (
SELECT id
FROM apps a2
LEFT JOIN apps_routes
... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20170524232621_create_orphaned_blobs.rb | Ruby | apache-2.0 | 203 | main | 260 | Sequel.migration do
change do
create_table :orphaned_blobs do
VCAP::Migration.common(self)
String :blob_key, unique: true
Integer :dirty_count
index :blob_key, name: :orphaned_blobs_blob_key_index, unique: true
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20170605182822_create_jobs.rb | Ruby | apache-2.0 | 203 | main | 211 | Sequel.migration do
change do
create_table :jobs do
VCAP::Migration.common(self)
String :state
String :operation
String :resource_guid
String :resource_type
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20180710115626_change_broker_catalog_descriptions_to_type_text.rb | Ruby | apache-2.0 | 203 | main | 580 | Sequel.migration do
up do
# In this PR https://github.com/cloudfoundry/cloud_controller_ng/pull/1193
# we are performing an API level validation on the length of description
# fields in the service broker catalog. However we do not want to break
# older brokers that may have long descriptions. Here we... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20190617181003_add_key_prefix_to_droplet_annotations.rb | Ruby | apache-2.0 | 203 | main | 221 | Sequel.migration do
change do
unless self[:droplet_annotations].columns.include?(:key_prefix)
alter_table(:droplet_annotations) do
add_column :key_prefix, String, size: 253
end
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20190617181509_add_key_prefix_to_stack_annotations.rb | Ruby | apache-2.0 | 203 | main | 217 | Sequel.migration do
change do
unless self[:stack_annotations].columns.include?(:key_prefix)
alter_table(:stack_annotations) do
add_column :key_prefix, String, size: 253
end
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20151008211628_add_lifecycle_info_to_droplet.rb | Ruby | apache-2.0 | 203 | main | 737 | Sequel.migration do
up do
add_column :v3_droplets, :stack_name, String, text: true, null: true
add_column :v3_droplets, :lifecycle, String, text: true, null: true
rename_column :v3_droplets, :procfile, :process_types, type: :text
add_column :v3_droplets, :execution_metadata, String, text: true, null: ... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20170214000310_create_clock_jobs.rb | Ruby | apache-2.0 | 203 | main | 234 | Sequel.migration do
change do
create_table :clock_jobs do
primary_key :id
String :name, null: false
index :name, unique: true, name: 'clock_jobs_name_unique'
DateTime :last_started_at
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20160510172035_increase_task_environment_variables_size.rb | Ruby | apache-2.0 | 203 | main | 285 | Sequel.migration do
up do
alter_table :tasks do
set_column_type :encrypted_environment_variables, String, text: true, null: true
end
end
down do
alter_table :tasks do
set_column_type :encrypted_environment_variables, String, null: true
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20160113223027_alter_apps_routes_table.rb | Ruby | apache-2.0 | 203 | main | 1,954 | Sequel.migration do
up do
alter_table :apps_routes do
# mysql requires foreign key to be dropped before index
drop_foreign_key [:app_id], name: :fk_apps_routes_app_id
drop_foreign_key [:route_id], name: :fk_apps_routes_route_id
drop_index %i[app_id route_id], name: :ar_app_id_route_id_ind... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20130725213922_create_events_table.rb | Ruby | apache-2.0 | 203 | main | 483 | Sequel.migration do
change do
create_table :events do
VCAP::Migration.common(self)
DateTime :timestamp, null: false
String :type, null: false
String :actor, null: false
String :actor_type, null: false
String :actee, null: false
String :actee_type, null: false
Strin... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20240219113000_add_routes_space_id_index.rb | Ruby | apache-2.0 | 203 | main | 499 | Sequel.migration do
no_transaction # to use the 'concurrently' option
up do
VCAP::Migration.with_concurrent_timeout(self) do
add_index :routes, :space_id, name: :routes_space_id_index, if_not_exists: true, concurrently: true if database_type == :postgres
end
end
down do
VCAP::Migration.with_... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20160808182741_isolation_segment.rb | Ruby | apache-2.0 | 203 | main | 408 | Sequel.migration do
# rubocop:disable Lint/BooleanSymbol
change do
create_table :isolation_segments do
VCAP::Migration.common(self)
String :name, null: false, case_insensitive: :true
index :name
end
alter_table :isolation_segments do
add_unique_constraint :name, name: :isolation... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20181120231620_create_organization_annotations_table.rb | Ruby | apache-2.0 | 203 | main | 222 | Sequel.migration do
change do
create_table(:organization_annotations) do
VCAP::Migration.common(self)
VCAP::Migration.annotations_common(self, :organization_annotations, :organizations)
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20191125192326_create_kpack_lifecycle_data.rb | Ruby | apache-2.0 | 203 | main | 378 | Sequel.migration do
change do
create_table(:kpack_lifecycle_data) do
VCAP::Migration.common(self)
String :build_guid, size: 255, null: false
foreign_key [:build_guid], :builds, key: :guid, name: :fk_kpack_lifecycle_build_guid
index [:build_guid], name: :fk_kpack_lifecycle_build_guid_index... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20190617182113_add_key_prefix_to_organization_annotations.rb | Ruby | apache-2.0 | 203 | main | 231 | Sequel.migration do
change do
unless self[:organization_annotations].columns.include?(:key_prefix)
alter_table(:organization_annotations) do
add_column :key_prefix, String, size: 253
end
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20260320141005_add_unique_constraint_to_revision_sidecars.rb | Ruby | apache-2.0 | 203 | main | 2,267 | Sequel.migration do
no_transaction # required for concurrently option on postgres
up do
transaction do
# remove duplicate entries if they exist
duplicates = self[:revision_sidecars].
select(:revision_guid, :name).
group(:revision_guid, :name).
... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20130806175100_support_30char_identifiers_for_oracle.rb | Ruby | apache-2.0 | 203 | main | 7,593 | # Copyright (c) 2009-2012 VMware, Inc.
def rename_foreign_key_internal(db, alter_table, table, current_name, new_name, &block)
processed = false
db.foreign_key_list(table).each do |fk|
next unless fk[:name] && fk[:name] == current_name
alter_table.drop_constraint current_name, type: :foreign_key
yield... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20170505163434_remove_unused_columns_from_builds.rb | Ruby | apache-2.0 | 203 | main | 203 | Sequel.migration do
change do
drop_column :builds, :docker_receipt_image
drop_column :builds, :buildpack_receipt_buildpack_guid
drop_column :builds, :buildpack_receipt_stack_name
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20130611175239_create_service_plan_visibilities_table.rb | Ruby | apache-2.0 | 203 | main | 501 | Sequel.migration do
change do
create_table :service_plan_visibilities do
VCAP::Migration.common(self, :spv)
Integer :service_plan_id, null: false
Integer :organization_id, null: false
index %i[organization_id service_plan_id], unique: true
foreign_key [:service_plan_id], :service_pl... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20160301215655_add_unique_constraint_on_apps_routes_table.rb | Ruby | apache-2.0 | 203 | main | 523 | Sequel.migration do
up do
# We are assuming with this DB migration that no apps_routes table currently
# has duplicate rows, according to the unique constraint
# of (app_id, route_id, app_port). This migration will fail otherwise.
alter_table :apps_routes do
add_unique_constraint %i[app_id rout... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20150515230939_add_case_insensitive_to_route_path.rb | Ruby | apache-2.0 | 203 | main | 281 | Sequel.migration do
up do
alter_table :routes do
set_column_type :path, String, default: '', null: false, case_insensitive: true
end
end
down do
alter_table :routes do
set_column_type :path, 'varchar(255)', default: '', null: false
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20220217141700_add_attempts_index_to_delayed_jobs.rb | Ruby | apache-2.0 | 203 | main | 262 | Sequel.migration do
up do
alter_table :delayed_jobs do
add_index :attempts, name: :delayed_jobs_attempts_index
end
end
down do
alter_table :delayed_jobs do
drop_index :attempts, name: :delayed_jobs_attempts_index
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20191218001006_fill_guid_and_timestamps_for_spaces_auditors.rb | Ruby | apache-2.0 | 203 | main | 298 | Sequel.migration do
up do
self[:spaces_auditors].where(role_guid: nil).update(
role_guid: VCAP::Migration.uuid_function(self),
updated_at: Sequel::CURRENT_TIMESTAMP
)
end
down do
# Not reversible. Rollback earlier migration to drop the columns filled here.
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20191218001015_fill_guid_and_timestamps_for_spaces_developers.rb | Ruby | apache-2.0 | 203 | main | 300 | Sequel.migration do
up do
self[:spaces_developers].where(role_guid: nil).update(
role_guid: VCAP::Migration.uuid_function(self),
updated_at: Sequel::CURRENT_TIMESTAMP
)
end
down do
# Not reversible. Rollback earlier migration to drop the columns filled here.
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20190221221532_create_revision_process_commands_table.rb | Ruby | apache-2.0 | 203 | main | 444 | Sequel.migration do
change do
create_table :revision_process_commands do
VCAP::Migration.common(self)
String :revision_guid, size: 255, null: false
index :revision_guid, name: :rev_commands_revision_guid_index
foreign_key [:revision_guid], :revisions, key: :guid, name: :rev_commands_revisi... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20240514113500_create_cnb_lifecycle_data.rb | Ruby | apache-2.0 | 203 | main | 2,122 | Sequel.migration do
# adding an index concurrently cannot be done within a transaction
no_transaction
up do
transaction do
create_table?(:cnb_lifecycle_data) do
VCAP::Migration.common(self, :cnb_lifecycle_data)
String :build_guid, size: 255
foreign_key [:build_guid], :builds, k... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20181127224109_add_vip_to_routes.rb | Ruby | apache-2.0 | 203 | main | 215 | Sequel.migration do
change do
alter_table :routes do
add_column :vip_offset, Integer, null: true, default: nil
add_index :vip_offset, unique: true, name: :routes_vip_offset_index
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20231113105256_add_service_plan_id_index.rb | Ruby | apache-2.0 | 203 | main | 508 | Sequel.migration do
no_transaction # to use the 'concurrently' option
up do
VCAP::Migration.with_concurrent_timeout(self) do
add_index :service_plan_visibilities, :service_plan_id, name: :spv_service_plan_id_index, concurrently: true if database_type == :postgres
end
end
down do
VCAP::Migrat... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20160914165525_migrate_v2_app_data_to_v3.rb | Ruby | apache-2.0 | 203 | main | 18,375 | Sequel.migration do
up do
collate_opts = {}
dbtype = if self.class.name.match?(/mysql/i)
collate_opts[:collate] = :utf8_bin
'mysql'
elsif self.class.name.match?(/postgres/i)
'postgres'
else
raise 'unknown database'
... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20180813221823_clear_process_command_and_metadata_command.rb | Ruby | apache-2.0 | 203 | main | 1,899 | Sequel.migration do
up do
processes_with_meta_commands = self[:processes].where(Sequel.like(:metadata, '%command%'))
processes_with_meta_commands.each do |process_record|
# for_update will acquire a row level lock in the database
# We need to force the dataset to evaluate by calling #first to get... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20180924142407_remove_uniqueness_on_index_unique_id_from_service_plans.rb | Ruby | apache-2.0 | 203 | main | 354 | Sequel.migration do
up do
alter_table :service_plans do
drop_index :unique_id
add_index :unique_id, name: :service_plans_unique_id_index, unique: false
end
end
down do
alter_table :service_plans do
drop_index :unique_id
add_index :unique_id, name: :service_plans_unique_id_inde... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20181030175334_create_org_labels.rb | Ruby | apache-2.0 | 203 | main | 479 | Sequel.migration do
change do
create_table(:org_labels) do
VCAP::Migration.common(self)
String :org_guid, size: 255
String :key_prefix, size: 253
String :key_name, size: 63
String :value, size: 63
foreign_key [:org_guid], :organizations, key: :guid, name: :fk_org_labels_org_g... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20260323144429_add_unique_constraint_to_revision_process_commands.rb | Ruby | apache-2.0 | 203 | main | 2,533 | Sequel.migration do # rubocop:disable Metrics/BlockLength
no_transaction # required for concurrently option on postgres
up do
transaction do
duplicates = self[:revision_process_commands].
select(:revision_guid, :process_type).
group(:revision_guid, :process_type).
... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20190109223733_create_stack_annotations_table.rb | Ruby | apache-2.0 | 203 | main | 201 | Sequel.migration do
change do
create_table(:stack_annotations) do
VCAP::Migration.common(self)
VCAP::Migration.annotations_common(self, :stack_annotations, :stacks)
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20160920170627_add_task_sequence_id.rb | Ruby | apache-2.0 | 203 | main | 210 | Sequel.migration do
change do
alter_table(:tasks) do
add_column :sequence_id, Integer
add_unique_constraint %i[app_guid sequence_id], name: :unique_task_app_guid_sequence_id
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20140724215343_add_feature_flags.rb | Ruby | apache-2.0 | 203 | main | 237 | Sequel.migration do
change do
create_table :feature_flags do
VCAP::Migration.common(self, :feature_flag)
String :name, null: false
Boolean :enabled, null: false
index :name, unique: true
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20191203153701_create_service_broker_metadata_tables.rb | Ruby | apache-2.0 | 203 | main | 400 | Sequel.migration do
change do
create_table(:service_broker_labels) do
VCAP::Migration.common(self)
VCAP::Migration.labels_common(self, :service_broker_labels, :service_brokers)
end
create_table(:service_broker_annotations) do
VCAP::Migration.common(self)
VCAP::Migration.annotation... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20130712215250_limit_service_instance_name_to_50_chars.rb | Ruby | apache-2.0 | 203 | main | 226 | Sequel.migration do
up do
alter_table :service_instances do
set_column_type :name, 'varchar(50)'
end
end
down do
alter_table :service_instances do
set_column_type :name, String
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20200211194856_change_revision_env_vars_to_text.rb | Ruby | apache-2.0 | 203 | main | 413 | Sequel.migration do
change do
alter_table(:revisions) do
# Make sure column type matches `encrypted_environment_variables` on apps table
# This is (necessarily) carrying forward mistakes of the past, see `include_string_size.rb`
# for details on why text columns shouldn't be used in ccdb's datab... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20150323234355_recreate_apps_v3_routes.rb | Ruby | apache-2.0 | 203 | main | 507 | Sequel.migration do
up do
drop_table :apps_v3_routes
create_table :apps_v3_routes do
primary_key :id
foreign_key :app_v3_id, :apps_v3
foreign_key :route_id, :routes
String :type
index :type
end
end
down do
drop_table :apps_v3_routes
create_table :apps_v3_routes ... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20130824002024_add_broker_id_to_services_and_nullable_provider_version_url.rb | Ruby | apache-2.0 | 203 | main | 332 | Sequel.migration do
change do
alter_table :services do
add_column :service_broker_id, Integer
add_foreign_key [:service_broker_id], :service_brokers, name: :fk_services_service_broker_id
set_column_allow_null :provider
set_column_allow_null :version
set_column_allow_null :url
en... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20180115151922_add_instances_and_bindings_retrievable_to_services.rb | Ruby | apache-2.0 | 203 | main | 236 | Sequel.migration do
change do
alter_table :services do
add_column :bindings_retrievable, :boolean, default: false, null: false
add_column :instances_retrievable, :boolean, default: false, null: false
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20150324232809_add_fk_v3_apps_packages_droplets_processes.rb | Ruby | apache-2.0 | 203 | main | 1,126 | Sequel.migration do
up do
alter_table(:apps_v3_routes) do
drop_foreign_key :app_v3_id
end
self[:apps_v3_routes].truncate
self[:apps_v3].truncate
self[:v3_droplets].truncate
self[:packages].truncate
run 'UPDATE apps SET app_guid = NULL;'
alter_table(:apps_v3_routes) do
add_... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20200826090000_create_route_binding_operations.rb | Ruby | apache-2.0 | 203 | main | 606 | Sequel.migration do
change do
create_table :route_binding_operations do
VCAP::Migration.timestamps(self, :route_binding_operations)
Integer :route_binding_id
String :state, size: 255, null: false
String :type, size: 255, null: false
String :description, size: 10_000
String :br... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20180515220732_create_primary_key_for_organizations_auditors.rb | Ruby | apache-2.0 | 203 | main | 394 | require File.expand_path('../../helpers/change_primary_key', __FILE__)
Sequel.migration do
up do
add_primary_key_to_table(:organizations_auditors, :organizations_auditors_pk)
end
down do
remove_primary_key_from_table(:organizations_auditors,
:organizations_auditors_pkey... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20190913184731_create_user_metadata_tables.rb | Ruby | apache-2.0 | 203 | main | 340 | Sequel.migration do
change do
create_table(:user_labels) do
VCAP::Migration.common(self)
VCAP::Migration.labels_common(self, :user_labels, :users)
end
create_table(:user_annotations) do
VCAP::Migration.common(self)
VCAP::Migration.annotations_common(self, :user_annotations, :users... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20180515221734_create_primary_key_for_spaces_developers.rb | Ruby | apache-2.0 | 203 | main | 369 | require File.expand_path('../../helpers/change_primary_key', __FILE__)
Sequel.migration do
up do
add_primary_key_to_table(:spaces_developers, :spaces_developers_pk)
end
down do
remove_primary_key_from_table(:spaces_developers,
:spaces_developers_pkey,
... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20220216124400_add_delayed_job_guid_index_to_jobs.rb | Ruby | apache-2.0 | 203 | main | 262 | Sequel.migration do
up do
alter_table :jobs do
add_index :delayed_job_guid, name: :jobs_delayed_job_guid_index
end
end
down do
alter_table :jobs do
drop_index :delayed_job_guid, name: :jobs_delayed_job_guid_index
end
end
end |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20240904132000_add_foreign_key_apps_droplet_guid.rb | Ruby | apache-2.0 | 203 | main | 1,888 | def get_column_definition(table, column)
fetch("SHOW FULL COLUMNS FROM `#{table}`;").all.find { |c| c[:Field] == column }
end
def verify_no_other_modification(definition_before, definition_after)
definition_after.each do |key, value|
raise "Column definition '#{key}' was changed from '#{definition_before[key]}... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20180515221623_create_primary_key_for_organizations_managers.rb | Ruby | apache-2.0 | 203 | main | 394 | require File.expand_path('../../helpers/change_primary_key', __FILE__)
Sequel.migration do
up do
add_primary_key_to_table(:organizations_managers, :organizations_managers_pk)
end
down do
remove_primary_key_from_table(:organizations_managers,
:organizations_managers_pkey... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20260318083940_add_unique_constraint_to_buildpacks.rb | Ruby | apache-2.0 | 203 | main | 2,821 | Sequel.migration do
no_transaction # required for concurrently option on postgres
up do
transaction do
# Remove duplicate entries if they exist
duplicates = self[:buildpacks].select(:name, :stack, :lifecycle).group(:name, :stack, :lifecycle).having { count(1) > 1 }
duplicates.each do |dup|
... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20130329165619_add_unique_id_to_service_plans.rb | Ruby | apache-2.0 | 203 | main | 873 | # Copyright (c) 2009-2012 VMware, Inc.
Sequel.migration do
change do
alter_table :service_plans do
add_column :unique_id, String
add_index :unique_id, unique: true
end
if self.class.name.match?(/mysql/i)
run <<~SQL.squish
UPDATE service_plans
SET unique_id =
... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20150127194942_create_service_instance_operations.rb | Ruby | apache-2.0 | 203 | main | 412 | Sequel.migration do
change do
create_table :service_instance_operations do
VCAP::Migration.common(self, :svc_inst_op)
Integer :service_instance_id
index :service_instance_id, name: :svc_instance_id_index
foreign_key [:service_instance_id], :service_instances, name: :fk_svc_inst_op_svc_inst... |
github | cloudfoundry/cloud_controller_ng | https://github.com/cloudfoundry/cloud_controller_ng | db/migrations/20170920143711_create_service_instance_shares.rb | Ruby | apache-2.0 | 203 | main | 554 | Sequel.migration do
change do
create_table :service_instance_shares do
String :service_instance_guid, null: false, size: 255
String :target_space_guid, null: false, size: 255
foreign_key [:service_instance_guid], :service_instances, key: :guid, name: :fk_service_instance_guid, on_delete: :casca... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.