@@ -2,11 +2,11 @@ package code.api.util.migration
22
33import java .time .format .DateTimeFormatter
44import java .time .{ZoneId , ZonedDateTime }
5-
65import code .api .util .APIUtil
76import code .api .util .migration .Migration .{DbFunction , saveLog }
87import code .model .{AppType , Consumer }
9- import net .liftweb .mapper .DB
8+ import net .liftweb .common .Full
9+ import net .liftweb .mapper .{DB , Schemifier }
1010import net .liftweb .util .{DefaultConnectionIdentifier , Helpers }
1111
1212object MigrationOfConsumer {
@@ -107,4 +107,52 @@ object MigrationOfConsumer {
107107 isSuccessful
108108 }
109109 }
110+
111+
112+ def alterTypeofAud (name : String ): Boolean = {
113+ DbFunction .tableExists(Consumer ) match {
114+ case true =>
115+ val startDate = System .currentTimeMillis()
116+ val commitId : String = APIUtil .gitCommit
117+ var isSuccessful = false
118+
119+ val executedSql =
120+ DbFunction .maybeWrite(true , Schemifier .infoF _) {
121+ APIUtil .getPropsValue(" db.driver" ) match {
122+ case Full (dbDriver) if dbDriver.contains(" com.microsoft.sqlserver.jdbc.SQLServerDriver" ) =>
123+ () =>
124+ """
125+ |ALTER TABLE consumer ALTER COLUMN aud VARCHAR(MAX) NULL;
126+ |""" .stripMargin
127+ case _ =>
128+ () =>
129+ """
130+ |ALTER TABLE consumer ALTER COLUMN aud TYPE text;
131+ |""" .stripMargin
132+ }
133+
134+ }
135+
136+ val endDate = System .currentTimeMillis()
137+ val comment : String =
138+ s """ Executed SQL:
139+ | $executedSql
140+ | """ .stripMargin
141+ isSuccessful = true
142+ saveLog(name, commitId, isSuccessful, startDate, endDate, comment)
143+ isSuccessful
144+
145+ case false =>
146+ val startDate = System .currentTimeMillis()
147+ val commitId : String = APIUtil .gitCommit
148+ val isSuccessful = false
149+ val endDate = System .currentTimeMillis()
150+ val comment : String =
151+ s """ ${Consumer ._dbTableNameLC} table does not exist """ .stripMargin
152+ saveLog(name, commitId, isSuccessful, startDate, endDate, comment)
153+ isSuccessful
154+ }
155+ }
156+
157+
110158}
0 commit comments