ERROR 42P01 (undefined_table) relation "transactions" does not exist
Closed this issue · 3 comments
Hello, sorry for the n00b question.
I'm getting the error "relation "transactions" does not exist" with the following code. The transactions table exists in the carbonite_default database. How do I get Ecto to prefix table names with a database name?
Thank you
%{meta: %{type: "signed_in"}, carbonite_prefix: "carbonite_default"}
|> Carbonite.Transaction.changeset()
|> Repo.insert!()
If you are using the Repo.insert!
API, you can use the prefix
option from Ecto to set the prefix:
%{meta: %{type: "signed_in"}}
|> Carbonite.Transaction.changeset()
|> Repo.insert!(prefix: "carbonite_default")
If you are using insert_transation
instead ( https://hexdocs.pm/carbonite/Carbonite.html#insert_transaction/3 )
Carbonite sets the prefix for you.
Since you were probably inspired by the example here in the main README, https://github.com/bitcrowd/carbonite#building-a-changeset-for-manual-insertion I think we should add this there as well, so other people are not confused by the same example, since the example would only work when the transactions
table sits in the default prefix of ecto (default
I believe). @maltoe, what do you think?
So if #54 gets merged and released you should also be able to do:
%{meta: %{type: "signed_in"}}
|> Carbonite.Transaction.changeset()
|> Repo.insert!()
since we now set the default prefixes for Ecto to be picked up.
Thank you! Carbonite is awesome!