summaryrefslogtreecommitdiff
path: root/db/migrate/20211028132247_create_packages_npm_metadata.rb
blob: cbe5429fca1f35132b142a1e366db9d252ba37c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

class CreatePackagesNpmMetadata < Gitlab::Database::Migration[1.0]
  disable_ddl_transaction!

  def up
    with_lock_retries do
      create_table :packages_npm_metadata, id: false do |t|
        t.references :package, primary_key: true, default: nil, index: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint
        t.jsonb :package_json, default: {}, null: false

        t.check_constraint 'char_length(package_json::text) < 20000'
      end
    end
  end

  def down
    with_lock_retries do
      drop_table :packages_npm_metadata
    end
  end
end