-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle creation and removing signing tags
- Loading branch information
Showing
16 changed files
with
173 additions
and
2 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
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,17 @@ | ||
# == Schema Information | ||
# | ||
# Table name: tags | ||
# | ||
# id :bigint not null, primary key | ||
# external_name :string | ||
# name :string not null | ||
# type :string not null | ||
# visible :boolean default(TRUE), not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# owner_id :bigint | ||
# tenant_id :bigint not null | ||
# user_id :integer | ||
# | ||
class SignatureRequestedTag < Tag | ||
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,18 @@ | ||
# == Schema Information | ||
# | ||
# Table name: tags | ||
# | ||
# id :bigint not null, primary key | ||
# external_name :string | ||
# name :string not null | ||
# type :string not null | ||
# visible :boolean default(TRUE), not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# owner_id :bigint | ||
# tenant_id :bigint not null | ||
# user_id :integer | ||
# | ||
class SignatureRequestedToTag < Tag | ||
belongs_to :user | ||
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,18 @@ | ||
# == Schema Information | ||
# | ||
# Table name: tags | ||
# | ||
# id :bigint not null, primary key | ||
# external_name :string | ||
# name :string not null | ||
# type :string not null | ||
# visible :boolean default(TRUE), not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# owner_id :bigint | ||
# tenant_id :bigint not null | ||
# user_id :integer | ||
# | ||
class SignedByTag < Tag | ||
belongs_to :user | ||
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,17 @@ | ||
# == Schema Information | ||
# | ||
# Table name: tags | ||
# | ||
# id :bigint not null, primary key | ||
# external_name :string | ||
# name :string not null | ||
# type :string not null | ||
# visible :boolean default(TRUE), not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# owner_id :bigint | ||
# tenant_id :bigint not null | ||
# user_id :integer | ||
# | ||
class SignedTag < Tag | ||
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
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
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
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,13 @@ | ||
class GenerateTenantSigningTags < ActiveRecord::Migration[7.0] | ||
def up | ||
Tenant.find_each do |tenant| | ||
tenant.create_signature_requested_tag!(name: "Na podpis", visible: true) | ||
tenant.create_signed_tag!(name: "Podpísané", visible: true) | ||
end | ||
end | ||
|
||
def down | ||
SignatureRequestedTag.destroy_all | ||
SignedTag.destroy_all | ||
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,26 @@ | ||
class AddUserIdToTags < ActiveRecord::Migration[7.0] | ||
def up | ||
add_column :tags, :user_id, :integer | ||
|
||
# `name` is needed because there was a `user_id` that is now `owner_id` before | ||
add_foreign_key :tags, :users, name: "tags_to_users" | ||
|
||
SignerGroup.includes(:users).find_each do |group| | ||
group.users.each do |user| | ||
SignerGroup.user_added_to_group(group, user) | ||
end | ||
end | ||
end | ||
|
||
def down | ||
SignerGroup.includes(:users).find_each do |group| | ||
group.users.each do |user| | ||
SignerGroup.user_removed_from_group(group, user) | ||
end | ||
end | ||
|
||
remove_foreign_key :tags, :users, name: "tags_to_users" | ||
|
||
remove_column :tags, :user_id, :integer | ||
end | ||
end |
17 changes: 17 additions & 0 deletions
17
db/migrate/20231204143711_add_unique_indexes_for_signings.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,17 @@ | ||
class AddUniqueIndexesForSignings < ActiveRecord::Migration[7.0] | ||
def up | ||
remove_index :group_memberships, :group_id | ||
add_index :group_memberships, [:group_id, :user_id], unique: true | ||
|
||
execute "CREATE UNIQUE INDEX signers_tags ON tags (tenant_id, type, user_id) WHERE (type IN ('SignatureRequestedToTag', 'SignedByTag') AND user_id IS NOT null);" | ||
execute "CREATE UNIQUE INDEX signings_tags ON tags (tenant_id, type) WHERE (type IN ('SignatureRequestedTag', 'SignedTag'));" | ||
end | ||
|
||
def down | ||
execute "DROP INDEX signings_tags;" | ||
execute "DROP INDEX signers_tags;" | ||
|
||
remove_index :group_memberships, [:group_id, :user_id], unique: true | ||
add_index :group_memberships, :group_id | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.