From 03d0b13c724b3fd303fa90641f3154e24e06e38c Mon Sep 17 00:00:00 2001 From: Collin Beczak <88843144+CollinBeczak@users.noreply.github.com> Date: Tue, 22 Oct 2024 21:55:36 -0500 Subject: [PATCH] Add active indicator column to tags table (#1154) * add active indicator column to tags table --- app/org/maproulette/framework/model/Tag.scala | 3 ++- .../framework/repository/TagRepository.scala | 17 +++++++++++------ conf/evolutions/default/96.sql | 7 +++++++ 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 conf/evolutions/default/96.sql diff --git a/app/org/maproulette/framework/model/Tag.scala b/app/org/maproulette/framework/model/Tag.scala index 3d2e13af..86990f4d 100644 --- a/app/org/maproulette/framework/model/Tag.scala +++ b/app/org/maproulette/framework/model/Tag.scala @@ -24,7 +24,8 @@ case class Tag( description: Option[String] = None, created: DateTime = DateTime.now(), modified: DateTime = DateTime.now(), - tagType: String = "challenges" + tagType: String = "challenges", + active: Boolean = true ) extends CacheObject[Long] /** diff --git a/app/org/maproulette/framework/repository/TagRepository.scala b/app/org/maproulette/framework/repository/TagRepository.scala index 26ac21f7..f95408dc 100644 --- a/app/org/maproulette/framework/repository/TagRepository.scala +++ b/app/org/maproulette/framework/repository/TagRepository.scala @@ -198,9 +198,10 @@ object TagRepository { get[Long]("tags.id") ~ get[String]("tags.name") ~ get[Option[String]]("tags.description") ~ - get[String]("tags.tag_type") map { - case id ~ name ~ description ~ tagType => - new Tag(id, name.toLowerCase, description, tagType = tagType) + get[String]("tags.tag_type") ~ + get[Boolean]("tags.active") map { + case id ~ name ~ description ~ tagType ~ active => + new Tag(id, name.toLowerCase, description, tagType = tagType, active = active) } } @@ -209,9 +210,13 @@ object TagRepository { get[Long]("tags.id") ~ get[String]("tags.name") ~ get[Option[String]]("tags.description") ~ - get[String]("tags.tag_type") map { - case taskId ~ id ~ name ~ description ~ tagType => { - new TaskTag(taskId, new Tag(id, name.toLowerCase, description, tagType = tagType)) + get[String]("tags.tag_type") ~ + get[Boolean]("tags.active") map { + case taskId ~ id ~ name ~ description ~ tagType ~ active => { + new TaskTag( + taskId, + new Tag(id, name.toLowerCase, description, tagType = tagType, active = active) + ) } } } diff --git a/conf/evolutions/default/96.sql b/conf/evolutions/default/96.sql new file mode 100644 index 00000000..fa3957c5 --- /dev/null +++ b/conf/evolutions/default/96.sql @@ -0,0 +1,7 @@ +# --- !Ups +ALTER TABLE IF EXISTS tags +ADD COLUMN active Boolean DEFAULT true;; + +# --- !Downs +ALTER TABLE IF EXISTS tags +DROP COLUMN active;;