-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #288 from lbestatlas/issue/237-workflow-index-upda…
…te-time workflow_index.update_time bugfix
- Loading branch information
Showing
7 changed files
with
115 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-DD"T"HH24:MI:SS.MS')::timestamp AT TIME ZONE '00:00' | ||
WHERE json_data->>'updateTime' IS NOT NULL; |
81 changes: 81 additions & 0 deletions
81
...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,81 @@ | ||
/* | ||
* Copyright 2024 Conductor Authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.netflix.conductor.postgres.config; | ||
|
||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
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 com.netflix.conductor.common.config.TestObjectMapperConfiguration; | ||
|
||
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())))); | ||
} | ||
} |