-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
¨caiovelp¨
committed
Dec 9, 2024
1 parent
2ba309e
commit d4e3103
Showing
6 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) Universidade Federal Fluminense (UFF). | ||
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file. | ||
|
||
# frozen_string_literal: true | ||
|
||
class Assertion < ApplicationRecord | ||
has_paper_trail | ||
|
||
attr_accessor :args | ||
belongs_to :query, inverse_of: :assertions, optional: false | ||
|
||
validates :name, presence: true | ||
validates :assertion_template, presence: true, on: :update | ||
|
||
def to_label | ||
"#{self.name}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class CreateAssertions < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :assertions do |t| | ||
t.string :name | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddQueryIdToAssertions < ActiveRecord::Migration[7.0] | ||
def change | ||
add_reference :assertions, :query, null: true, foreign_key: true | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
db/migrate/20241209223142_populate_query_id_in_assertions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class PopulateQueryIdInAssertions < ActiveRecord::Migration[7.0] | ||
def up | ||
default_query = Query.first | ||
Assertion.update_all(query_id: default_query.id) if default_query | ||
end | ||
|
||
def down | ||
# No need to revert data changes | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ChangeQueryIdInAssertions < ActiveRecord::Migration[7.0] | ||
def change | ||
change_column_null :assertions, :query_id, false | ||
end | ||
end |