Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Martin Dinov
POD
Commits
95fc66de
Verified
Commit
95fc66de
authored
5 years ago
by
Vasili Novikov
Browse files
Options
Download
Email Patches
Plain Diff
enforce foreign keys
parent
dcda21e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.rs
+5
-4
src/main.rs
with
5 additions
and
4 deletions
+5
-4
src/main.rs
+
5
-
4
View file @
95fc66de
...
...
@@ -42,11 +42,8 @@ async fn main() {
.parent
()
.expect
(
"Failed to get parent directory for database"
);
create_dir_all
(
sqlite_dir
)
.expect
(
"Failed to create database directory"
);
let
sqlite
=
SqliteConnectionManager
::
file
(
&
sqlite_file
);
let
sqlite
:
Pool
<
SqliteConnectionManager
>
=
r2d2
::
Pool
::
new
(
sqlite
)
.expect
(
"Failed to create r2d2 SQLite connection pool"
);
// Create a new rusqlite connection for migration
, t
his is a suboptimal solution for now,
// Create a new rusqlite connection for migration
. T
his is a suboptimal solution for now,
// and should be improved later to use the existing connection manager (TODO)
let
mut
conn
=
rusqlite
::
Connection
::
open
(
&
sqlite_file
)
.expect
(
"Failed to open database for refinery migrations"
);
...
...
@@ -55,6 +52,10 @@ async fn main() {
.expect
(
"Failed to run refinery migrations"
);
conn
.close
()
.expect
(
"Failed to close connection"
);
let
sqlite
=
SqliteConnectionManager
::
file
(
&
sqlite_file
)
.with_init
(|
c
|
c
.execute_batch
(
"PRAGMA foreign_keys = ON;"
));
let
sqlite
:
Pool
<
SqliteConnectionManager
>
=
r2d2
::
Pool
::
new
(
sqlite
)
.expect
(
"Failed to create r2d2 SQLite connection pool"
);
database_init
::
init
(
&
sqlite
);
// Start web framework
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets