Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
1a07aa45
Unverified
Commit
1a07aa45
authored
8 months ago
by
Tim Macdonald
Committed by
GitHub
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Add type hints to dev/migrate.clj to avoid reflection warnings (#45679)
parent
5c62992b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dev/src/dev/migrate.clj
+16
-11
16 additions, 11 deletions
dev/src/dev/migrate.clj
with
16 additions
and
11 deletions
dev/src/dev/migrate.clj
+
16
−
11
View file @
1a07aa45
...
...
@@ -8,12 +8,16 @@
[
toucan2.core
:as
t2
])
(
:import
(
liquibase
Contexts
Liquibase
RuntimeEnvironment
)
(
liquibase.changelog
ChangeLogIterator
)
(
liquibase.change
Change
)
(
liquibase.changelog
ChangeLogIterator
ChangeSet
DatabaseChangeLog
)
(
liquibase.changelog.filter
ChangeSetFilter
)
(
liquibase.changelog.visitor
ListVisitor
)
(
liquibase.database
Database
)
(
liquibase.database.core
H2Database
MySQLDatabase
PostgresDatabase
MariaDBDatabase
)
(
liquibase.exception
RollbackImpossibleException
)
(
liquibase.sqlgenerator
SqlGeneratorFactory
)))
(
liquibase.sql
Sql
)
(
liquibase.sqlgenerator
SqlGeneratorFactory
)
(
liquibase.statement
SqlStatement
)))
(
set!
*warn-on-reflection*
true
)
...
...
@@ -112,11 +116,11 @@
(
defn-
stmts-to-sql
[
stmts
sql-generator-factory
database
]
(
str/join
"\n"
(
for
[
stmt
stmts
sql
(
.generateSql
^
SqlGeneratorFactory
sql-generator-factory
stmt
database
)]
(
.toString
sql
))))
sql
(
.generateSql
^
SqlGeneratorFactory
sql-generator-factory
^
SqlStatement
stmt
^
Database
database
)]
(
.toString
^
Sql
sql
))))
(
defn-
change->sql
[
change
sql-generator-factory
database
]
[
^
Change
change
sql-generator-factory
database
]
{
:forward
(
stmts-to-sql
(
.generateStatements
change
database
)
sql-generator-factory
database
)
:rollback
(
try
(
stmts-to-sql
(
.generateRollbackStatements
change
database
)
sql-generator-factory
database
)
(
catch
RollbackImpossibleException
e
...
...
@@ -141,12 +145,13 @@
([
id
db-type
:-
[
:enum
:postgres
:mysql
:mariadb
:h2
]]
(
t2/with-connection
[
conn
]
(
liquibase/with-liquibase
[
^
Liquibase
liquibase
conn
]
(
let
[
database
(
liquibase-database
db-type
)
change-log-iterator
(
ChangeLogIterator.
(
.getDatabaseChangeLog
liquibase
)
(
into-array
ChangeSetFilter
[]))
list-visistor
(
ListVisitor.
)
runtime-env
(
RuntimeEnvironment.
database
(
Contexts.
)
nil
)
_
(
.run
change-log-iterator
list-visistor
runtime-env
)
change-set
(
first
(
filter
#
(
=
id
(
.getId
%
))
(
.getSeenChangeSets
list-visistor
)))
(
let
[
database
(
liquibase-database
db-type
)
change-log-iterator
(
ChangeLogIterator.
^
DatabaseChangeLog
(
.getDatabaseChangeLog
liquibase
)
^
"[Lliquibase.changelog.filter.ChangeSetFilter;"
(
into-array
ChangeSetFilter
[]))
list-visistor
(
ListVisitor.
)
runtime-env
(
RuntimeEnvironment.
database
(
Contexts.
)
nil
)
_
(
.run
change-log-iterator
list-visistor
runtime-env
)
^
ChangeSet
change-set
(
first
(
filter
#
(
=
id
(
.getId
^
ChangeSet
%
))
(
.getSeenChangeSets
list-visistor
)))
sql-generator-factory
(
SqlGeneratorFactory/getInstance
)]
(
reduce
(
fn
[
acc
data
]
;; merge all changes in one change set into one single :forward and :rollback
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment