Migrate: @@unique : Unexpected token. Expected one of: alphanumeric identifier.

Created on 25 Jun 2019  路  5Comments  路  Source: prisma/migrate

The attribute @@unique seems to fail on lift save. I used that schema from the rfc and lift website (explicit many to many relation) :

datasource db {
  provider = "mysql"
  url      = "mysql://root@localhost:3306/yolo"
}

model Blog {
  id       Int       @id
  authors  Writer[]
}

model Writer {
  id      Int     @id
  blogs   Blog[]
}

// many to many
model BlogsWriters {
  blog      Blog
  author    Writer
  is_owner  Boolean

  @@unique(author, blog)
}

result is:

~/testPrisma/prisma$ prisma2 lift save
Error: Error in lift engine for rpc listMigrations:
thread 'main' panicked at 'loading the connector failed.: DataModelErrors { code: 1001, errors: ["Unexpected token. Expected one of: alphanumeric identifier."] }', src/libcore/result.rs:997:5
stack backtrace:
    0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
        at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
    1: std::sys_common::backtrace::_print
        at src/libstd/sys_common/backtrace.rs:71
    2: std::panicking::default_hook::{{closure}}
        at src/libstd/sys_common/backtrace.rs:59
        at src/libstd/panicking.rs:197
    3: std::panicking::default_hook
        at src/libstd/panicking.rs:211
    4: std::panicking::rust_panic_with_hook
        at src/libstd/panicking.rs:474
    5: std::panicking::continue_panic_fmt
        at src/libstd/panicking.rs:381
    6: rust_begin_unwind
        at src/libstd/panicking.rs:308
    7: core::panicking::panic_fmt
        at src/libcore/panicking.rs:85
    8: core::result::unwrap_failed
    9: migration_core::migration_engine::MigrationEngine::init
    10: <F as jsonrpc_core::calls::RpcMethodSimple>::call
    11: <F as jsonrpc_core::calls::RpcMethod<T>>::call
    12: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
    13: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
    14: <futures::future::map::Map<A,F> as futures::future::Future>::poll
    15: <futures::future::either::Either<A,B> as futures::future::Future>::poll
    16: futures::task_impl::std::set
    17: std::thread::local::LocalKey<T>::with
    18: futures::future::Future::wait
    19: jsonrpc_core::io::IoHandler<M>::handle_request_sync
    20: migration_core::rpc_api::RpcApi::handle
    21: migration_engine::main
    22: std::rt::lang_start::{{closure}}
    23: std::panicking::try::do_call
        at src/libstd/rt.rs:49
        at src/libstd/panicking.rs:293
    24: __rust_maybe_catch_panic
        at src/libpanic_unwind/lib.rs:87
    25: std::rt::lang_start_internal
        at src/libstd/panicking.rs:272
        at src/libstd/panic.rs:388
        at src/libstd/rt.rs:48
    26: main
    27: __libc_start_main
    28: _start
bu1-repro-available kinbug

Most helpful comment

Hey @Justkant, this is just a matter of us implementing 馃槉. It's a large internal change which will take some time, but we're well aware of the issue and want to solve it asap.

All 5 comments

Hi @tontonrally!

Thanks for bringing this up! We don't yet support composite indexes, but it's planned for the future. I've pinged the team to fix up the docs now and we'll be supporting these types of indexes soon.

Even though the index is not supported, this is a parser error which should not happen.

Hi!

Do you need help moving this feature forward or is the team already on this ?

Hey @Justkant, this is just a matter of us implementing 馃槉. It's a large internal change which will take some time, but we're well aware of the issue and want to solve it asap.

I opened a feature/improvement idea issue to return a better error message for this type of syntax errors: https://github.com/prisma/prisma/issues/2317

Since this is not exactly a bug, but an unhelpful error message, let's close this issue and continue the discussion on the other one. Thanks for reporting this!

Was this page helpful?
0 / 5 - 0 ratings