Commit 6d8c8ac7 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add associations and cascade delete for foreign keys

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 58eee015
class Packages::Package < ActiveRecord::Base
belongs_to :project
has_many :package_files
has_one :maven_metadatum
end
......@@ -3,7 +3,7 @@ class CreatePackagesPackageFiles < ActiveRecord::Migration
def change
create_table :packages_package_files do |t|
t.references :package, index: true, foreign_key: true, null: false
t.references :package, index: true, foreign_key: { on_delete: :cascade }, null: false
t.string :file
t.integer :file_type
t.integer :size
......
class CreatePackagesPackages < ActiveRecord::Migration
def change
create_table :packages_packages do |t|
t.references :project, index: true, foreign_key: true, null: false
t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false
t.string :name
t.string :version
......
class CreatePackagesMavenMetadata < ActiveRecord::Migration
def change
create_table :packages_maven_metadata do |t|
t.references :package, index: true, foreign_key: true, null: false
t.references :package, index: true, foreign_key: { on_delete: :cascade }, null: false
t.string :app_group, null: false
t.string :app_name, null: false
t.string :app_version, null: false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment