-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81e5037
commit 9328ccd
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
openbas-api/src/main/java/io/openbas/migration/V3_43__Payloads_default_values.java
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,24 @@ | ||
package io.openbas.migration; | ||
|
||
import org.flywaydb.core.api.migration.BaseJavaMigration; | ||
import org.flywaydb.core.api.migration.Context; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.sql.Connection; | ||
import java.sql.Statement; | ||
|
||
@Component | ||
public class V3_43__Payloads_default_values extends BaseJavaMigration { | ||
|
||
@Override | ||
public void migrate(Context context) throws Exception { | ||
Connection connection = context.getConnection(); | ||
Statement select = connection.createStatement(); | ||
|
||
select.executeUpdate("UPDATE payloads SET payload_source = 'MANUAL' WHERE payload_source IS NULL;"); | ||
select.executeUpdate("UPDATE payloads SET payload_status = 'UNVERIFIED' WHERE payload_source IS NULL;"); | ||
|
||
select.execute("ALTER TABLE payloads ALTER COLUMN payload_source SET DEFAULT 'MANUAL';"); | ||
select.execute("ALTER TABLE payloads ALTER COLUMN payload_status SET DEFAULT 'UNVERIFIED';"); | ||
} | ||
} |