fixed fastsql upgrade
This commit is contained in:
+8
-4
@@ -18,13 +18,17 @@ public class FastsqlSchemaTest {
|
||||
@Test
|
||||
public void testSimple() throws FileNotFoundException, IOException {
|
||||
SchemaRepository repository = new SchemaRepository(JdbcConstants.MYSQL);
|
||||
String sql = "create table yushitai_test.card_record ( id bigint auto_increment) auto_increment=256 "
|
||||
+ "; alter table yushitai_test.card_record add column customization_id bigint unsigned NOT NULL COMMENT 'TEST' ;"
|
||||
+ "; rename table yushitai_test.card_record to yushitai_test._card_record_del;";
|
||||
String sql = "create table yushitai_test.card_record ( id bigint auto_increment, name varchar(32) DEFAULT NULL) auto_increment=256 "
|
||||
+ "alter table yushitai_test.card_record add index index_name(name) ;"
|
||||
+ "alter table yushitai_test.card_record add index index_name(name) ;"
|
||||
+ "alter table yushitai_test.card_record add Constraint pk_id PRIMARY KEY (id);"
|
||||
+ "alter table yushitai_test.card_record add Constraint pk_id PRIMARY KEY (id);"
|
||||
+ "alter table yushitai_test.card_record add Constraint UNIQUE index uk_name(name);"
|
||||
+ "alter table yushitai_test.card_record add Constraint UNIQUE index uk_name(name);";
|
||||
repository.console(sql);
|
||||
|
||||
repository.setDefaultSchema("yushitai_test");
|
||||
SchemaObject table = repository.findTable("_card_record_del");
|
||||
SchemaObject table = repository.findTable("card_record");
|
||||
System.out.println(table.getStatement().toString());
|
||||
}
|
||||
}
|
||||
|
||||
+15
@@ -37,4 +37,19 @@ public class MemoryTableMeta_DDL_Test {
|
||||
meta = memoryTableMeta.find("yushitai_test", "_card_record_gho");
|
||||
Assert.assertNull(meta);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() throws Throwable {
|
||||
MemoryTableMeta memoryTableMeta = new MemoryTableMeta();
|
||||
URL url = Thread.currentThread().getContextClassLoader().getResource("dummy.txt");
|
||||
File dummyFile = new File(url.getFile());
|
||||
File create = new File(dummyFile.getParent() + "/ddl", "ddl_test2.sql");
|
||||
String sql = StringUtils.join(IOUtils.readLines(new FileInputStream(create)), "\n");
|
||||
memoryTableMeta.apply(null, "test", sql, null);
|
||||
|
||||
TableMeta meta = memoryTableMeta.find("yushitai_test", "card_record");
|
||||
System.out.println(meta);
|
||||
Assert.assertEquals(meta.getFieldMetaByName("id").isKey(), true);
|
||||
Assert.assertEquals(meta.getFieldMetaByName("name").isUnique(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE yushitai_test.card_record (
|
||||
id bigint AUTO_INCREMENT,
|
||||
name varchar(32) DEFAULT NULL,
|
||||
alias varchar(32) DEFAULT NULL,
|
||||
INDEX index_name(name),
|
||||
CONSTRAINT pk_id PRIMARY KEY (id),
|
||||
UNIQUE uk_name (name,alias)
|
||||
) AUTO_INCREMENT = 256
|
||||
Reference in New Issue
Block a user