Skip to content

Commit f7fc296

Browse files
authored
Merge pull request #39 from Javakky-pxv/master
fix: if MySQL, check the existence of the table.
2 parents 5fa687f + 868ccc7 commit f7fc296

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/org/casbin/adapter/JDBCBaseAdapter.java

+7
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ protected void migrate() throws SQLException {
7979
String productName = conn.getMetaData().getDatabaseProductName();
8080

8181
switch (productName) {
82+
case "MySQL":
83+
String hasTableSql = "SHOW TABLES LIKE 'casbin_rule';";
84+
ResultSet rs = stmt.executeQuery(hasTableSql);
85+
if (rs.next()) {
86+
return;
87+
}
88+
break;
8289
case "Oracle":
8390
sql = "declare begin execute immediate 'CREATE TABLE CASBIN_RULE(id NUMBER(5, 0) not NULL primary key, ptype VARCHAR(100) not NULL, v0 VARCHAR(100), v1 VARCHAR(100), v2 VARCHAR(100), v3 VARCHAR(100), v4 VARCHAR(100), v5 VARCHAR(100))'; " +
8491
"exception when others then " +

0 commit comments

Comments
 (0)