1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2018 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.migrations.db
21 
22 import java.sql.Connection
23 import scala.util.chaining.scalaUtilChainingOps
24 import io.circe.syntax._
25 import io.circe.parser.decode
26 import io.circe.generic.auto._
27 import SqlTools.ImprovedResultSet
28 import org.make.core.technical.Multilingual
29 import org.make.core.reference.Language
30 import org.make.core.demographics.LabelsValue
31 
32 @SuppressWarnings(Array("org.wartremover.warts.TraversableOps"))
33 class V137_0__Multilingual_demographics extends Migration {
34 
35   private case class LegacyLabelValue(label: String, value: String)
36 
37   @SuppressWarnings(Array("org.wartremover.warts.Throw"))
38   private def migrateParameters(params: String, lang: String): String =
39     decode[Seq[LegacyLabelValue]](params) match {
40       case Right(list) =>
41         list
42           .map({
43             case LegacyLabelValue(label, value) =>
44               LabelsValue(Multilingual(Language(lang) -> label), value)
45           })
46           .asJson
47           .noSpaces
48       case Left(err) => throw err
49     }
50 
51   private val addNewColumns: Connection => Unit =
52     _.prepareStatement("""
53         |ALTER TABLE demographics_card
54         |ADD COLUMN languages STRING[], ADD COLUMN titles JSONB
55       """.stripMargin)
56       .execute()
57 
58   private val destroyOldCumns: Connection => Unit =
59     _.prepareStatement("ALTER TABLE demographics_card DROP COLUMN language, DROP COLUMN title")
60       .execute()
61 
62   private def genUpdateLangQuery(cardId: String, lang: String, title: String, params: String)(
63     connection: Connection
64   ): Unit = {
65     val parameters = migrateParameters(params, lang)
66     connection
67       .prepareStatement(s"""
68         |UPDATE demographics_card
69         |SET (languages, titles, parameters) = (ARRAY['$lang'], $$$${"$lang": "$title"}$$$$, $$$$${parameters}$$$$)
70         |WHERE id = '$cardId'
71       """.stripMargin)
72       .execute()
73   }
74 
75   override def migrate(connection: Connection): Unit =
76     connection
77       .prepareStatement(s"SELECT id, language, title, parameters FROM demographics_card")
78       .executeQuery
79       .toMaps("id", "language", "title", "parameters")
80       .tap(_ => connection.commit())
81       .tap(_ => addNewColumns(connection))
82       .tap(_ => connection.commit())
83       .foreach(
84         dataMap =>
85           genUpdateLangQuery(dataMap("id"), dataMap("language"), dataMap("title"), dataMap("parameters"))(connection)
86       )
87       .tap(_ => connection.commit())
88       .tap(_ => destroyOldCumns(connection))
89 }
Line Stmt Id Pos Tree Symbol Tests Code
39 20757 1465 - 1465 ApplyToImplicitArgs io.circe.Decoder.decodeSeq circe.this.Decoder.decodeSeq[V137_0__Multilingual_demographics.this.LegacyLabelValue](circe.this.Decoder.importedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]((new io.circe.export.Exported[io.circe.Decoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]]((shapeless.lazily.apply[io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]]({ val inst$macro$12: io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue] = { final class anon$importedDecoder$macro$11 extends AnyRef with Serializable { def <init>(): anon$importedDecoder$macro$11 = { anon$importedDecoder$macro$11.super.<init>(); () }; <stable> <accessor> lazy val inst$macro$1: io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue] = decoding.this.DerivedDecoder.deriveDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue, shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](shapeless.this.LabelledGeneric.materializeProduct[V137_0__Multilingual_demographics.this.LegacyLabelValue, (Symbol @@ String("label")) :: (Symbol @@ String("value")) :: shapeless.HNil, String :: String :: shapeless.HNil, shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](DefaultSymbolicLabelling.instance[V137_0__Multilingual_demographics.this.LegacyLabelValue, (Symbol @@ String("label")) :: (Symbol @@ String("value")) :: shapeless.HNil](::.apply[Symbol @@ String("label"), (Symbol @@ String("value")) :: shapeless.HNil.type](scala.Symbol.apply("label").asInstanceOf[Symbol @@ String("label")], ::.apply[Symbol @@ String("value"), shapeless.HNil.type](scala.Symbol.apply("value").asInstanceOf[Symbol @@ String("value")], HNil))), Generic.instance[V137_0__Multilingual_demographics.this.LegacyLabelValue, String :: String :: shapeless.HNil](((x0$3: V137_0__Multilingual_demographics.this.LegacyLabelValue) => x0$3 match { case (label: String, value: String): V137_0__Multilingual_demographics.this.LegacyLabelValue((label$macro$8 @ _), (value$macro$9 @ _)) => ::.apply[String, String :: shapeless.HNil.type](label$macro$8, ::.apply[String, shapeless.HNil.type](value$macro$9, HNil)).asInstanceOf[String :: String :: shapeless.HNil] }), ((x0$4: String :: String :: shapeless.HNil) => x0$4 match { case (head: String, tail: String :: shapeless.HNil): String :: String :: shapeless.HNil((label$macro$6 @ _), (head: String, tail: shapeless.HNil): String :: shapeless.HNil((value$macro$7 @ _), HNil)) => V137_0__Multilingual_demographics.this.LegacyLabelValue.apply(label$macro$6, value$macro$7) })), hlist.this.ZipWithKeys.hconsZipWithKeys[Symbol @@ String("label"), String, (Symbol @@ String("value")) :: shapeless.HNil, String :: shapeless.HNil, shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](hlist.this.ZipWithKeys.hconsZipWithKeys[Symbol @@ String("value"), String, shapeless.HNil, shapeless.HNil, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](hlist.this.ZipWithKeys.hnilZipWithKeys, Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("value")]](scala.Symbol.apply("value").asInstanceOf[Symbol @@ String("value")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("value")]])), Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("label")]](scala.Symbol.apply("label").asInstanceOf[Symbol @@ String("label")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("label")]])), scala.this.<:<.refl[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]), shapeless.Lazy.apply[io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]](anon$importedDecoder$macro$11.this.inst$macro$10)).asInstanceOf[io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]]; <stable> <accessor> lazy val inst$macro$10: io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] = ({ final class $anon extends io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] { def <init>(): <$anon: io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]> = { $anon.super.<init>(); () }; private[this] val circeGenericDecoderForvalue: io.circe.Decoder[String] = circe.this.Decoder.decodeString; final def apply(c: io.circe.HCursor): io.circe.Decoder.Result[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] = ReprDecoder.consResults[io.circe.Decoder.Result, Symbol @@ String("label"), String, shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForvalue.tryDecode(c.downField("label")), ReprDecoder.consResults[io.circe.Decoder.Result, Symbol @@ String("value"), String, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForvalue.tryDecode(c.downField("value")), ReprDecoder.hnilResult)(io.circe.Decoder.resultInstance))(io.circe.Decoder.resultInstance); final override def decodeAccumulating(c: io.circe.HCursor): io.circe.Decoder.AccumulatingResult[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] = ReprDecoder.consResults[io.circe.Decoder.AccumulatingResult, Symbol @@ String("label"), String, shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForvalue.tryDecodeAccumulating(c.downField("label")), ReprDecoder.consResults[io.circe.Decoder.AccumulatingResult, Symbol @@ String("value"), String, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForvalue.tryDecodeAccumulating(c.downField("value")), ReprDecoder.hnilResultAccumulating)(io.circe.Decoder.accumulatingResultInstance))(io.circe.Decoder.accumulatingResultInstance) }; new $anon() }: io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]).asInstanceOf[io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]] }; new anon$importedDecoder$macro$11().inst$macro$1 }; shapeless.Lazy.apply[io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]](inst$macro$12) }): io.circe.Decoder[V137_0__Multilingual_demographics.this.LegacyLabelValue])): io.circe.export.Exported[io.circe.Decoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]])))
39 19782 1436 - 1473 ApplyToImplicitArgs io.circe.Parser.decode io.circe.parser.`package`.decode[Seq[V137_0__Multilingual_demographics.this.LegacyLabelValue]](params)(circe.this.Decoder.decodeSeq[V137_0__Multilingual_demographics.this.LegacyLabelValue](circe.this.Decoder.importedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]((new io.circe.export.Exported[io.circe.Decoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]]((shapeless.lazily.apply[io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]]({ val inst$macro$12: io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue] = { final class anon$importedDecoder$macro$11 extends AnyRef with Serializable { def <init>(): anon$importedDecoder$macro$11 = { anon$importedDecoder$macro$11.super.<init>(); () }; <stable> <accessor> lazy val inst$macro$1: io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue] = decoding.this.DerivedDecoder.deriveDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue, shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](shapeless.this.LabelledGeneric.materializeProduct[V137_0__Multilingual_demographics.this.LegacyLabelValue, (Symbol @@ String("label")) :: (Symbol @@ String("value")) :: shapeless.HNil, String :: String :: shapeless.HNil, shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](DefaultSymbolicLabelling.instance[V137_0__Multilingual_demographics.this.LegacyLabelValue, (Symbol @@ String("label")) :: (Symbol @@ String("value")) :: shapeless.HNil](::.apply[Symbol @@ String("label"), (Symbol @@ String("value")) :: shapeless.HNil.type](scala.Symbol.apply("label").asInstanceOf[Symbol @@ String("label")], ::.apply[Symbol @@ String("value"), shapeless.HNil.type](scala.Symbol.apply("value").asInstanceOf[Symbol @@ String("value")], HNil))), Generic.instance[V137_0__Multilingual_demographics.this.LegacyLabelValue, String :: String :: shapeless.HNil](((x0$3: V137_0__Multilingual_demographics.this.LegacyLabelValue) => x0$3 match { case (label: String, value: String): V137_0__Multilingual_demographics.this.LegacyLabelValue((label$macro$8 @ _), (value$macro$9 @ _)) => ::.apply[String, String :: shapeless.HNil.type](label$macro$8, ::.apply[String, shapeless.HNil.type](value$macro$9, HNil)).asInstanceOf[String :: String :: shapeless.HNil] }), ((x0$4: String :: String :: shapeless.HNil) => x0$4 match { case (head: String, tail: String :: shapeless.HNil): String :: String :: shapeless.HNil((label$macro$6 @ _), (head: String, tail: shapeless.HNil): String :: shapeless.HNil((value$macro$7 @ _), HNil)) => V137_0__Multilingual_demographics.this.LegacyLabelValue.apply(label$macro$6, value$macro$7) })), hlist.this.ZipWithKeys.hconsZipWithKeys[Symbol @@ String("label"), String, (Symbol @@ String("value")) :: shapeless.HNil, String :: shapeless.HNil, shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](hlist.this.ZipWithKeys.hconsZipWithKeys[Symbol @@ String("value"), String, shapeless.HNil, shapeless.HNil, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](hlist.this.ZipWithKeys.hnilZipWithKeys, Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("value")]](scala.Symbol.apply("value").asInstanceOf[Symbol @@ String("value")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("value")]])), Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("label")]](scala.Symbol.apply("label").asInstanceOf[Symbol @@ String("label")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("label")]])), scala.this.<:<.refl[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]), shapeless.Lazy.apply[io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]](anon$importedDecoder$macro$11.this.inst$macro$10)).asInstanceOf[io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]]; <stable> <accessor> lazy val inst$macro$10: io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] = ({ final class $anon extends io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] { def <init>(): <$anon: io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]> = { $anon.super.<init>(); () }; private[this] val circeGenericDecoderForvalue: io.circe.Decoder[String] = circe.this.Decoder.decodeString; final def apply(c: io.circe.HCursor): io.circe.Decoder.Result[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] = ReprDecoder.consResults[io.circe.Decoder.Result, Symbol @@ String("label"), String, shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForvalue.tryDecode(c.downField("label")), ReprDecoder.consResults[io.circe.Decoder.Result, Symbol @@ String("value"), String, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForvalue.tryDecode(c.downField("value")), ReprDecoder.hnilResult)(io.circe.Decoder.resultInstance))(io.circe.Decoder.resultInstance); final override def decodeAccumulating(c: io.circe.HCursor): io.circe.Decoder.AccumulatingResult[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] = ReprDecoder.consResults[io.circe.Decoder.AccumulatingResult, Symbol @@ String("label"), String, shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForvalue.tryDecodeAccumulating(c.downField("label")), ReprDecoder.consResults[io.circe.Decoder.AccumulatingResult, Symbol @@ String("value"), String, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForvalue.tryDecodeAccumulating(c.downField("value")), ReprDecoder.hnilResultAccumulating)(io.circe.Decoder.accumulatingResultInstance))(io.circe.Decoder.accumulatingResultInstance) }; new $anon() }: io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]).asInstanceOf[io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]] }; new anon$importedDecoder$macro$11().inst$macro$1 }; shapeless.Lazy.apply[io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]](inst$macro$12) }): io.circe.Decoder[V137_0__Multilingual_demographics.this.LegacyLabelValue])): io.circe.export.Exported[io.circe.Decoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]]))))
39 21263 1465 - 1465 ApplyToImplicitArgs io.circe.LowPriorityDecoders.importedDecoder circe.this.Decoder.importedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]((new io.circe.export.Exported[io.circe.Decoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]]((shapeless.lazily.apply[io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]]({ val inst$macro$12: io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue] = { final class anon$importedDecoder$macro$11 extends AnyRef with Serializable { def <init>(): anon$importedDecoder$macro$11 = { anon$importedDecoder$macro$11.super.<init>(); () }; <stable> <accessor> lazy val inst$macro$1: io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue] = decoding.this.DerivedDecoder.deriveDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue, shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](shapeless.this.LabelledGeneric.materializeProduct[V137_0__Multilingual_demographics.this.LegacyLabelValue, (Symbol @@ String("label")) :: (Symbol @@ String("value")) :: shapeless.HNil, String :: String :: shapeless.HNil, shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](DefaultSymbolicLabelling.instance[V137_0__Multilingual_demographics.this.LegacyLabelValue, (Symbol @@ String("label")) :: (Symbol @@ String("value")) :: shapeless.HNil](::.apply[Symbol @@ String("label"), (Symbol @@ String("value")) :: shapeless.HNil.type](scala.Symbol.apply("label").asInstanceOf[Symbol @@ String("label")], ::.apply[Symbol @@ String("value"), shapeless.HNil.type](scala.Symbol.apply("value").asInstanceOf[Symbol @@ String("value")], HNil))), Generic.instance[V137_0__Multilingual_demographics.this.LegacyLabelValue, String :: String :: shapeless.HNil](((x0$3: V137_0__Multilingual_demographics.this.LegacyLabelValue) => x0$3 match { case (label: String, value: String): V137_0__Multilingual_demographics.this.LegacyLabelValue((label$macro$8 @ _), (value$macro$9 @ _)) => ::.apply[String, String :: shapeless.HNil.type](label$macro$8, ::.apply[String, shapeless.HNil.type](value$macro$9, HNil)).asInstanceOf[String :: String :: shapeless.HNil] }), ((x0$4: String :: String :: shapeless.HNil) => x0$4 match { case (head: String, tail: String :: shapeless.HNil): String :: String :: shapeless.HNil((label$macro$6 @ _), (head: String, tail: shapeless.HNil): String :: shapeless.HNil((value$macro$7 @ _), HNil)) => V137_0__Multilingual_demographics.this.LegacyLabelValue.apply(label$macro$6, value$macro$7) })), hlist.this.ZipWithKeys.hconsZipWithKeys[Symbol @@ String("label"), String, (Symbol @@ String("value")) :: shapeless.HNil, String :: shapeless.HNil, shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](hlist.this.ZipWithKeys.hconsZipWithKeys[Symbol @@ String("value"), String, shapeless.HNil, shapeless.HNil, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](hlist.this.ZipWithKeys.hnilZipWithKeys, Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("value")]](scala.Symbol.apply("value").asInstanceOf[Symbol @@ String("value")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("value")]])), Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("label")]](scala.Symbol.apply("label").asInstanceOf[Symbol @@ String("label")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("label")]])), scala.this.<:<.refl[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]), shapeless.Lazy.apply[io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]](anon$importedDecoder$macro$11.this.inst$macro$10)).asInstanceOf[io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]]; <stable> <accessor> lazy val inst$macro$10: io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] = ({ final class $anon extends io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] { def <init>(): <$anon: io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]> = { $anon.super.<init>(); () }; private[this] val circeGenericDecoderForvalue: io.circe.Decoder[String] = circe.this.Decoder.decodeString; final def apply(c: io.circe.HCursor): io.circe.Decoder.Result[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] = ReprDecoder.consResults[io.circe.Decoder.Result, Symbol @@ String("label"), String, shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForvalue.tryDecode(c.downField("label")), ReprDecoder.consResults[io.circe.Decoder.Result, Symbol @@ String("value"), String, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForvalue.tryDecode(c.downField("value")), ReprDecoder.hnilResult)(io.circe.Decoder.resultInstance))(io.circe.Decoder.resultInstance); final override def decodeAccumulating(c: io.circe.HCursor): io.circe.Decoder.AccumulatingResult[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] = ReprDecoder.consResults[io.circe.Decoder.AccumulatingResult, Symbol @@ String("label"), String, shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForvalue.tryDecodeAccumulating(c.downField("label")), ReprDecoder.consResults[io.circe.Decoder.AccumulatingResult, Symbol @@ String("value"), String, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForvalue.tryDecodeAccumulating(c.downField("value")), ReprDecoder.hnilResultAccumulating)(io.circe.Decoder.accumulatingResultInstance))(io.circe.Decoder.accumulatingResultInstance) }; new $anon() }: io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]).asInstanceOf[io.circe.generic.decoding.ReprDecoder[shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("value"),String] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]] }; new anon$importedDecoder$macro$11().inst$macro$1 }; shapeless.Lazy.apply[io.circe.generic.decoding.DerivedDecoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]](inst$macro$12) }): io.circe.Decoder[V137_0__Multilingual_demographics.this.LegacyLabelValue])): io.circe.export.Exported[io.circe.Decoder[V137_0__Multilingual_demographics.this.LegacyLabelValue]]))
42 21677 1516 - 1673 Apply scala.collection.IterableOps.map list.map[org.make.core.demographics.LabelsValue](((x0$5: V137_0__Multilingual_demographics.this.LegacyLabelValue) => x0$5 match { case (label: String, value: String): V137_0__Multilingual_demographics.this.LegacyLabelValue((label @ _), (value @ _)) => org.make.core.demographics.LabelsValue.apply(org.make.core.technical.Multilingual.apply[String](scala.Predef.ArrowAssoc[org.make.core.reference.Language](org.make.core.reference.Language.apply(lang)).->[String](label)), value) }))
44 19957 1603 - 1660 Apply org.make.core.demographics.LabelsValue.apply org.make.core.demographics.LabelsValue.apply(org.make.core.technical.Multilingual.apply[String](scala.Predef.ArrowAssoc[org.make.core.reference.Language](org.make.core.reference.Language.apply(lang)).->[String](label)), value)
44 21422 1628 - 1651 Apply scala.Predef.ArrowAssoc.-> scala.Predef.ArrowAssoc[org.make.core.reference.Language](org.make.core.reference.Language.apply(lang)).->[String](label)
44 20525 1615 - 1652 Apply org.make.core.technical.Multilingual.apply org.make.core.technical.Multilingual.apply[String](scala.Predef.ArrowAssoc[org.make.core.reference.Language](org.make.core.reference.Language.apply(lang)).->[String](label))
46 20583 1685 - 1685 Select org.make.core.demographics.LabelsValue.codec demographics.this.LabelsValue.codec
46 19726 1685 - 1685 ApplyToImplicitArgs io.circe.Encoder.encodeSeq circe.this.Encoder.encodeSeq[org.make.core.demographics.LabelsValue](demographics.this.LabelsValue.codec)
47 21341 1516 - 1711 Select io.circe.Json.noSpaces io.circe.syntax.`package`.EncoderOps[Seq[org.make.core.demographics.LabelsValue]](list.map[org.make.core.demographics.LabelsValue](((x0$5: V137_0__Multilingual_demographics.this.LegacyLabelValue) => x0$5 match { case (label: String, value: String): V137_0__Multilingual_demographics.this.LegacyLabelValue((label @ _), (value @ _)) => org.make.core.demographics.LabelsValue.apply(org.make.core.technical.Multilingual.apply[String](scala.Predef.ArrowAssoc[org.make.core.reference.Language](org.make.core.reference.Language.apply(lang)).->[String](label)), value) }))).asJson(circe.this.Encoder.encodeSeq[org.make.core.demographics.LabelsValue](demographics.this.LabelsValue.codec)).noSpaces
48 20759 1736 - 1745 Throw <nosymbol> throw err
56 19786 1807 - 1972 Apply java.sql.PreparedStatement.execute org.make.api.databasetest x$1.prepareStatement(scala.Predef.augmentString("\n |ALTER TABLE demographics_card\n |ADD COLUMN languages STRING[], ADD COLUMN titles JSONB\n ").stripMargin).execute()
56 21383 1970 - 1970 Literal <nosymbol> org.make.api.databasetest ()
60 19599 2136 - 2136 Literal <nosymbol> org.make.api.databasetest ()
60 20532 2030 - 2138 Apply java.sql.PreparedStatement.execute org.make.api.databasetest x$2.prepareStatement("ALTER TABLE demographics_card DROP COLUMN language, DROP COLUMN title").execute()
65 21680 2297 - 2328 Apply org.make.api.migrations.db.V137_0__Multilingual_demographics.migrateParameters V137_0__Multilingual_demographics.this.migrateParameters(params, lang)
72 19692 2590 - 2590 Literal <nosymbol> ()
72 20587 2333 - 2592 Apply java.sql.PreparedStatement.execute connection.prepareStatement(scala.Predef.augmentString(("\n |UPDATE demographics_card\n |SET (languages, titles, parameters) = (ARRAY[\'".+(lang).+("\'], $${\"").+(lang).+("\": \"").+(title).+("\"}$$, $$").+(parameters).+("$$)\n |WHERE id = \'").+(cardId).+("\'\n "): String)).stripMargin).execute()
79 21346 2657 - 2832 Apply org.make.api.migrations.db.SqlTools.ImprovedResultSet.toMaps org.make.api.databasetest SqlTools.ImprovedResultSet(connection.prepareStatement(("SELECT id, language, title, parameters FROM demographics_card": String)).executeQuery()).toMaps("id", "language", "title", "parameters")
80 19921 2657 - 2869 Apply scala.util.ChainingOps.tap org.make.api.databasetest scala.util.`package`.chaining.scalaUtilChainingOps[scala.collection.mutable.ArrayBuffer[Map[String,String]]](SqlTools.ImprovedResultSet(connection.prepareStatement(("SELECT id, language, title, parameters FROM demographics_card": String)).executeQuery()).toMaps("id", "language", "title", "parameters")).tap[Unit](((x$3: scala.collection.mutable.ArrayBuffer[Map[String,String]]) => connection.commit()))
80 20785 2849 - 2868 Apply java.sql.Connection.commit org.make.api.databasetest connection.commit()
81 20489 2657 - 2912 Apply scala.util.ChainingOps.tap org.make.api.databasetest scala.util.`package`.chaining.scalaUtilChainingOps[scala.collection.mutable.ArrayBuffer[Map[String,String]]](scala.util.`package`.chaining.scalaUtilChainingOps[scala.collection.mutable.ArrayBuffer[Map[String,String]]](SqlTools.ImprovedResultSet(connection.prepareStatement(("SELECT id, language, title, parameters FROM demographics_card": String)).executeQuery()).toMaps("id", "language", "title", "parameters")).tap[Unit](((x$3: scala.collection.mutable.ArrayBuffer[Map[String,String]]) => connection.commit()))).tap[Unit](((x$4: scala.collection.mutable.ArrayBuffer[Map[String,String]]) => V137_0__Multilingual_demographics.this.addNewColumns.apply(connection)))
81 21461 2886 - 2911 Apply scala.Function1.apply org.make.api.databasetest V137_0__Multilingual_demographics.this.addNewColumns.apply(connection)
82 19602 2929 - 2948 Apply java.sql.Connection.commit org.make.api.databasetest connection.commit()
83 20713 2657 - 3110 Apply scala.collection.IterableOnceOps.foreach org.make.api.databasetest scala.util.`package`.chaining.scalaUtilChainingOps[scala.collection.mutable.ArrayBuffer[Map[String,String]]](scala.util.`package`.chaining.scalaUtilChainingOps[scala.collection.mutable.ArrayBuffer[Map[String,String]]](scala.util.`package`.chaining.scalaUtilChainingOps[scala.collection.mutable.ArrayBuffer[Map[String,String]]](SqlTools.ImprovedResultSet(connection.prepareStatement(("SELECT id, language, title, parameters FROM demographics_card": String)).executeQuery()).toMaps("id", "language", "title", "parameters")).tap[Unit](((x$3: scala.collection.mutable.ArrayBuffer[Map[String,String]]) => connection.commit()))).tap[Unit](((x$4: scala.collection.mutable.ArrayBuffer[Map[String,String]]) => V137_0__Multilingual_demographics.this.addNewColumns.apply(connection)))).tap[Unit](((x$5: scala.collection.mutable.ArrayBuffer[Map[String,String]]) => connection.commit())).foreach[Unit](((dataMap: Map[String,String]) => V137_0__Multilingual_demographics.this.genUpdateLangQuery(dataMap.apply("id"), dataMap.apply("language"), dataMap.apply("title"), dataMap.apply("parameters"))(connection)))
85 21604 2995 - 3102 Apply org.make.api.migrations.db.V137_0__Multilingual_demographics.genUpdateLangQuery V137_0__Multilingual_demographics.this.genUpdateLangQuery(dataMap.apply("id"), dataMap.apply("language"), dataMap.apply("title"), dataMap.apply("parameters"))(connection)
87 19694 3127 - 3146 Apply java.sql.Connection.commit org.make.api.databasetest connection.commit()
87 21303 2657 - 3147 Apply scala.util.ChainingOps.tap org.make.api.databasetest scala.util.`package`.chaining.scalaUtilChainingOps[Unit](scala.util.`package`.chaining.scalaUtilChainingOps[scala.collection.mutable.ArrayBuffer[Map[String,String]]](scala.util.`package`.chaining.scalaUtilChainingOps[scala.collection.mutable.ArrayBuffer[Map[String,String]]](scala.util.`package`.chaining.scalaUtilChainingOps[scala.collection.mutable.ArrayBuffer[Map[String,String]]](SqlTools.ImprovedResultSet(connection.prepareStatement(("SELECT id, language, title, parameters FROM demographics_card": String)).executeQuery()).toMaps("id", "language", "title", "parameters")).tap[Unit](((x$3: scala.collection.mutable.ArrayBuffer[Map[String,String]]) => connection.commit()))).tap[Unit](((x$4: scala.collection.mutable.ArrayBuffer[Map[String,String]]) => V137_0__Multilingual_demographics.this.addNewColumns.apply(connection)))).tap[Unit](((x$5: scala.collection.mutable.ArrayBuffer[Map[String,String]]) => connection.commit())).foreach[Unit](((dataMap: Map[String,String]) => V137_0__Multilingual_demographics.this.genUpdateLangQuery(dataMap.apply("id"), dataMap.apply("language"), dataMap.apply("title"), dataMap.apply("parameters"))(connection)))).tap[Unit](((x$6: Unit) => connection.commit()))
88 20332 3164 - 3191 Apply scala.Function1.apply org.make.api.databasetest V137_0__Multilingual_demographics.this.destroyOldCumns.apply(connection)
88 19865 2657 - 3192 Apply scala.util.ChainingOps.tap org.make.api.databasetest scala.util.`package`.chaining.scalaUtilChainingOps[Unit](scala.util.`package`.chaining.scalaUtilChainingOps[Unit](scala.util.`package`.chaining.scalaUtilChainingOps[scala.collection.mutable.ArrayBuffer[Map[String,String]]](scala.util.`package`.chaining.scalaUtilChainingOps[scala.collection.mutable.ArrayBuffer[Map[String,String]]](scala.util.`package`.chaining.scalaUtilChainingOps[scala.collection.mutable.ArrayBuffer[Map[String,String]]](SqlTools.ImprovedResultSet(connection.prepareStatement(("SELECT id, language, title, parameters FROM demographics_card": String)).executeQuery()).toMaps("id", "language", "title", "parameters")).tap[Unit](((x$3: scala.collection.mutable.ArrayBuffer[Map[String,String]]) => connection.commit()))).tap[Unit](((x$4: scala.collection.mutable.ArrayBuffer[Map[String,String]]) => V137_0__Multilingual_demographics.this.addNewColumns.apply(connection)))).tap[Unit](((x$5: scala.collection.mutable.ArrayBuffer[Map[String,String]]) => connection.commit())).foreach[Unit](((dataMap: Map[String,String]) => V137_0__Multilingual_demographics.this.genUpdateLangQuery(dataMap.apply("id"), dataMap.apply("language"), dataMap.apply("title"), dataMap.apply("parameters"))(connection)))).tap[Unit](((x$6: Unit) => connection.commit()))).tap[Unit](((x$7: Unit) => V137_0__Multilingual_demographics.this.destroyOldCumns.apply(connection)))