Support duplicate index detection, max constraint names - Internal changes for DB Migration / DDL generation #369

This commit is contained in:
Robin Bygrave
2015-08-06 07:39:50 +12:00
parent efd5e16511
commit 9e170b40f6
5 changed files with 177 additions and 23 deletions
@@ -17,13 +17,13 @@ public class DdlNamingConventionTest {
@Test
public void testUniqueConstraintName() throws Exception {
assertThat(defaultNaming.uniqueConstraintName("[foo_bar]", "[jim]")).isEqualTo("uq_foo_bar_jim");
assertThat(defaultNaming.uniqueConstraintName("[foo_bar]", "[jim]", 1)).isEqualTo("uq_foo_bar_jim");
}
@Test
public void testCheckConstraintName() throws Exception {
assertThat(defaultNaming.checkConstraintName("[foo_bar]", "[jim]")).isEqualTo("ck_foo_bar_jim");
assertThat(defaultNaming.checkConstraintName("[foo_bar]", "[jim]", 1)).isEqualTo("ck_foo_bar_jim");
}
@Test
@@ -0,0 +1,25 @@
package com.avaje.ebean.dbmigration.ddlgeneration.platform;
import org.junit.Test;
import static org.junit.Assert.*;
public class IndexSetTest {
@Test
public void test() {
BaseTableDdl.IndexSet set = new BaseTableDdl.IndexSet();
assertTrue(set.add(new String[]{"one_column"}));
assertTrue(set.add(new String[]{"two_column"}));
assertFalse(set.add(new String[]{"one_column"}));
assertTrue(set.add(new String[]{"a", "b"}));
assertTrue(set.add(new String[]{"b","c"}));
assertTrue(set.add(new String[]{"a"}));
assertFalse(set.add(new String[]{"a", "b"}));
}
}