forked from conductor-oss/conductor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Remove the v13 migration - Replace with migration script with one that adds update_time with a default of 'epoch' if the column doesn't exist, and sets the default of 'epoch' if the column does exist - Fix the PostgresIndexDao.indexWorkflow to also set the update_time during an UPDATE - Make the backfill script for update_time separate an optional and fix the timestamp to include milliseconds
- Loading branch information
1 parent
a28e0e9
commit 8eec176
Showing
7 changed files
with
96 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
6 changes: 6 additions & 0 deletions
6
...es-persistence/src/main/resources/db/migration_postgres/V13.1__workflow_index_columns.sql
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,6 @@ | ||
ALTER TABLE workflow_index | ||
ADD COLUMN IF NOT EXISTS update_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT TIMESTAMP WITH TIME ZONE 'epoch'; | ||
|
||
-- SET DEFAULT AGAIN IN CASE COLUMN ALREADY EXISTED from deleted V13 migration | ||
ALTER TABLE workflow_index | ||
ALTER COLUMN update_time SET DEFAULT TIMESTAMP WITH TIME ZONE 'epoch'; |
8 changes: 0 additions & 8 deletions
8
...gres-persistence/src/main/resources/db/migration_postgres/V13__workflow_index_columns.sql
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
.../main/resources/db/migration_postgres_data/V13.2__workflow_index_backfill_update_time.sql
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,4 @@ | ||
-- Optional back-fill script to populate updateTime historically. | ||
UPDATE workflow_index | ||
SET update_time = to_timestamp(json_data->>'updateTime', 'YYYY-MM-DDTHH24:MI:SS.MSZ')::timestamp WITH time zone | ||
WHERE json_data->>'updateTime' IS NOT NULL; |
62 changes: 62 additions & 0 deletions
62
...st/java/com/netflix/conductor/postgres/config/PostgresConfigurationDataMigrationTest.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,62 @@ | ||
package com.netflix.conductor.postgres.config; | ||
|
||
import com.netflix.conductor.common.config.TestObjectMapperConfiguration; | ||
import org.flywaydb.core.Flyway; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.core.io.support.ResourcePatternResolver; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.TestPropertySource; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
@ContextConfiguration( | ||
classes = { | ||
TestObjectMapperConfiguration.class, | ||
PostgresConfiguration.class, | ||
FlywayAutoConfiguration.class | ||
}) | ||
@RunWith(SpringRunner.class) | ||
@TestPropertySource( | ||
properties = { | ||
"conductor.app.asyncIndexingEnabled=false", | ||
"conductor.elasticsearch.version=0", | ||
"conductor.indexing.type=postgres", | ||
"conductor.postgres.applyDataMigrations=false", | ||
"spring.flyway.clean-disabled=false" | ||
}) | ||
@SpringBootTest | ||
public class PostgresConfigurationDataMigrationTest { | ||
|
||
@Autowired | ||
Flyway flyway; | ||
|
||
@Autowired | ||
ResourcePatternResolver resourcePatternResolver; | ||
|
||
// clean the database between tests. | ||
@Before | ||
public void before() { | ||
flyway.migrate(); | ||
} | ||
|
||
@Test | ||
public void dataMigrationIsNotAppliedWhenDisabled() throws Exception { | ||
var files = resourcePatternResolver.getResources("classpath:db/migration_postgres_data/*"); | ||
Arrays.stream(flyway.info().applied()).forEach(migrationInfo -> | ||
assertTrue("Data migration wrongly applied: " + migrationInfo.getScript(), | ||
Arrays.stream(files) | ||
.map(Resource::getFilename) | ||
.filter(Objects::nonNull) | ||
.noneMatch(fileName -> fileName.contains(migrationInfo.getScript())))); | ||
} | ||
} |