mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 17:51:13 +08:00
Improve repository models and migration [SCI-1267]
This commit is contained in:
parent
0dc0c7d096
commit
85e81e9ea2
4 changed files with 4 additions and 8 deletions
|
@ -7,6 +7,7 @@ class Repository < ActiveRecord::Base
|
|||
auto_strip_attributes :name, nullify: false
|
||||
validates :name,
|
||||
presence: true,
|
||||
uniqueness: { scope: :team },
|
||||
length: { maximum: Constants::NAME_MAX_LENGTH }
|
||||
validates :team, presence: true
|
||||
validates :created_by, presence: true
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class RepositoryColumn < ActiveRecord::Base
|
||||
belongs_to :repository
|
||||
belongs_to :team
|
||||
belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User'
|
||||
has_many :repository_cells, dependent: :destroy
|
||||
has_many :repository_rows, through: :repository_cells
|
||||
|
@ -11,8 +10,8 @@ class RepositoryColumn < ActiveRecord::Base
|
|||
validates :name,
|
||||
presence: true,
|
||||
length: { maximum: Constants::NAME_MAX_LENGTH },
|
||||
uniqueness: { scope: :team, case_sensitive: true }
|
||||
validates :team, :data_type, presence: true
|
||||
uniqueness: { scope: :repository, case_sensitive: true }
|
||||
validates :created_by, presence: true
|
||||
validates :repository, presence: true
|
||||
validates :data_type, presence: true
|
||||
end
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class RepositoryRow < ActiveRecord::Base
|
||||
belongs_to :repository
|
||||
belongs_to :team
|
||||
belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User'
|
||||
has_many :repository_cells, dependent: :destroy
|
||||
has_many :repository_columns, through: :repository_cells
|
||||
|
@ -9,6 +8,5 @@ class RepositoryRow < ActiveRecord::Base
|
|||
validates :name,
|
||||
presence: true,
|
||||
length: { maximum: Constants::NAME_MAX_LENGTH }
|
||||
validates :team, presence: true
|
||||
validates :created_by, presence: true
|
||||
end
|
||||
|
|
|
@ -11,7 +11,6 @@ class AddCustomRepositories < ActiveRecord::Migration
|
|||
|
||||
create_table :repository_columns do |t|
|
||||
t.belongs_to :repository, index: true
|
||||
t.belongs_to :team, index: true
|
||||
t.integer :created_by_id, null: false
|
||||
t.string :name
|
||||
t.integer :data_type, null: false
|
||||
|
@ -22,9 +21,8 @@ class AddCustomRepositories < ActiveRecord::Migration
|
|||
|
||||
create_table :repository_rows do |t|
|
||||
t.belongs_to :repository, index: true
|
||||
t.belongs_to :team, index: true
|
||||
t.integer :created_by_id, null: false
|
||||
t.string :name
|
||||
t.string :name, index: true
|
||||
t.timestamps null: true
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue