prisma / prisma1

💾 Database Tools incl. ORM, Migrations and Admin UI (Postgres, MySQL & MongoDB) [deprecated]
https://v1.prisma.io/docs/
Apache License 2.0
16.55k stars 865 forks source link

TiDB support #3814

Closed Victorkangsh closed 5 years ago

Victorkangsh commented 5 years ago

TiDB support

TiDB is an open source distributed scalable hybrid transactional and analytical processing (HTAP) database built by PingCAP.

TiDB is compatible with mysql, and it test well at small datamodel, but when i deploy a large datamodal it doesn't work. The error is here:

Encountered exception while applying migration. Rolling back. java.sql.SQLException: (conn=4) can't run multi schema change
java.sql.SQLException: (conn=4) can't run multi schema change
    at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:184)
    at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:106)
    at org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:235)
    at org.mariadb.jdbc.MariaDbPreparedStatementClient.executeInternal(MariaDbPreparedStatementClient.java:224)
    at org.mariadb.jdbc.MariaDbPreparedStatementClient.execute(MariaDbPreparedStatementClient.java:159)
    at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)
    at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java)
    at slick.jdbc.StatementInvoker.results(StatementInvoker.scala:38)
    at slick.jdbc.StatementInvoker.iteratorTo(StatementInvoker.scala:21)
    at slick.jdbc.Invoker.first(Invoker.scala:30)
    at slick.jdbc.Invoker.first$(Invoker.scala:29)
    at slick.jdbc.StatementInvoker.first(StatementInvoker.scala:15)
    at slick.jdbc.StreamingInvokerAction$HeadAction.run(StreamingInvokerAction.scala:52)
    at slick.jdbc.StreamingInvokerAction$HeadAction.run(StreamingInvokerAction.scala:51)
    at slick.basic.BasicBackend$DatabaseDef$$anon$2.liftedTree1$1(BasicBackend.scala:275)
    at slick.basic.BasicBackend$DatabaseDef$$anon$2.run(BasicBackend.scala:275)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLException: can't run multi schema change
Query is: ALTER TABLE `default@default`.`Account` ADD COLUMN `unionId` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL   , ADD UNIQUE INDEX `unionId_UNIQUE` (`unionId`(191) ASC), ALGORITHM = INPLACE
    at org.mariadb.jdbc.internal.util.LogQueryTool.exceptionWithQuery(LogQueryTool.java:146)
    at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQuery(AbstractQueryProtocol.java:217)
    at org.mariadb.jdbc.MariaDbPreparedStatementClient.executeInternal(MariaDbPreparedStatementClient.java:218)
    ... 15 more

This datamodal is work well on mysql. I am not sure which side can solve this problem better and look forward to the proposal.

ENV: prisma:1.23

Victorkangsh commented 5 years ago

Ok, this issue is due to TiDB can't run multi schema change currently. And it will supported in future.

And to show how to combine prisma with tidb, I created a repo for people interested in tidb.

https://github.com/Victorkangsh/prisma-tidb-local