You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.1 KiB
Java
29 lines
1.1 KiB
Java
package com.yau.digitalrmb.identity;
|
|
|
|
import com.yau.digitalrmb.identity.infrastructure.persistence.PlatformUserSnapshotSchemaUpgrade;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
@SpringBootTest
|
|
@ActiveProfiles("test")
|
|
class PlatformUserSnapshotSchemaUpgradeTest {
|
|
@Autowired private JdbcTemplate jdbcTemplate;
|
|
@Autowired private PlatformUserSnapshotSchemaUpgrade schemaUpgrade;
|
|
|
|
@Test
|
|
void restoresMissingProfileColumnWithPortableAlterStatement() {
|
|
jdbcTemplate.execute("ALTER TABLE platform_user_snapshot DROP COLUMN student_id");
|
|
|
|
schemaUpgrade.ensureColumns();
|
|
|
|
Integer count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS "
|
|
+ "WHERE LOWER(TABLE_NAME) = 'platform_user_snapshot' AND LOWER(COLUMN_NAME) = 'student_id'", Integer.class);
|
|
assertThat(count).isEqualTo(1);
|
|
}
|
|
}
|