Sha256: fdb8accebb7f9995444728110ee449df8c16e1ce5d3eb43968c49ec9178353bb

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

Sequel.migration do
  up do
    # SQLite does not support dropping columns until version 3.35, which is not in the EL8 ecosystem as of March, 2024.
    create_table(:repositories_users2) do
      foreign_key :repository_id, :repositories, on_delete: :cascade
      foreign_key :user_id, :users, on_delete: :cascade
      primary_key %i[repository_id user_id]
      index %i[repository_id user_id]
    end
    run "INSERT INTO repositories_users2(repository_id, user_id) SELECT repository_id, user_id from repositories_users"

    drop_table(:repositories_users)
    rename_table(:repositories_users2, :repositories_users)
  end

  down do
    create_table(:repositories_users2) do
      foreign_key :repository_id, :repositories
      foreign_key :user_id, :users
      primary_key %i[repository_id user_id]
      index %i[repository_id user_id]
    end
    run "INSERT INTO repositories_users2(repository_id, user_id) SELECT repository_id, user_id from repositories_users"

    drop_table(:repositories_users)
    rename_table(:repositories_users2, :repositories_users)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smart_proxy_container_gateway-3.2.0 lib/smart_proxy_container_gateway/sequel_migrations/004_users_repositories_cascade_delete.rb
smart_proxy_container_gateway-3.1.1 lib/smart_proxy_container_gateway/sequel_migrations/004_users_repositories_cascade_delete.rb
smart_proxy_container_gateway-3.1.0 lib/smart_proxy_container_gateway/sequel_migrations/004_users_repositories_cascade_delete.rb
smart_proxy_container_gateway-2.0.0 lib/smart_proxy_container_gateway/sequel_migrations/004_users_repositories_cascade_delete.rb