exqlite
exqlite copied to clipboard
mix ecto.migrate creates an encrypted db, mix ecto.create doesn't
when using sqlcipher, the mix ecto.migrate
command (after mix ecto.create
) results in the following error:
[error] GenServer #PID<0.372.0> terminating
** (MatchError) no match of right hand side value: {:error, "file is not a database"}
(exqlite 0.10.1) lib/exqlite/connection.ex:325: Exqlite.Connection.get_pragma/2
(exqlite 0.10.1) lib/exqlite/connection.ex:334: Exqlite.Connection.maybe_set_pragma/3
(exqlite 0.10.1) lib/exqlite/connection.ex:428: Exqlite.Connection.do_connect/2
(db_connection 2.4.2) lib/db_connection/connection.ex:82: DBConnection.Connection.connect/2
(connection 1.1.0) lib/connection.ex:622: Connection.enter_connect/5
(stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Exqlite.Connection
interestingly, using mix ecto.migrate
right after mix ecto.drop
results in the following error:
[error] Exqlite.Connection (#PID<0.372.0>) failed to connect: ** (Exqlite.Error) database is locked
but immediately afterwards the db is created, the migration is successful and the db is correctly encrypted. Is this the expected behavior? How come mix ecto.migrate
creates the db?
@ConnorRigby may have more insight into this than I do. I have not played much with the encrypted database stuff.
I think the issue is that storage_up
https://github.com/elixir-sqlite/ecto_sqlite3/blob/6fdb3e45024f83e0c862abe5aff7662657dc3b24/lib/ecto/adapters/sqlite3.ex#L467 does not set the PRAGMA KEY
as the open function does (see https://github.com/elixir-sqlite/exqlite/blob/main/lib/exqlite/connection.ex#L446)
@warmwaffles What do you think about changing the storage_up
function to use Exqlite.Connection.connect/1
?