Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Vasili Novikov
Pod
Commits
7224bb02
Unverified
Commit
7224bb02
authored
4 years ago
by
Vasili Novikov
Browse files
Options
Download
Email Patches
Plain Diff
Separate schema file from compilation
parent
3963df38
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Dockerfile
+2
-1
Dockerfile
src/constants.rs
+2
-0
src/constants.rs
src/database_migrate_schema.rs
+4
-3
src/database_migrate_schema.rs
with
8 additions
and
4 deletions
+8
-4
Dockerfile
+
2
-
1
View file @
7224bb02
...
...
@@ -25,7 +25,7 @@ RUN set -x && \
#### After the dependencies are built, copy the sources and build the real thing.
COPY
res
re
s
COPY
res
/migrations res/migration
s
COPY
build.rs build.rs
COPY
src src
COPY
benches benches
...
...
@@ -38,6 +38,7 @@ RUN cargo build --release && mv target/release/pod ./ && rm -rf target
FROM
debian:buster-slim
COPY
--from=cargo-build /usr/bin/docker /usr/bin/docker
COPY
--from=cargo-build /usr/src/pod/pod pod
COPY
res/autogenerated_database_schema.json res/autogenerated_database_schema.json
RUN
apt-get update
&&
apt-get
install
-y
libsqlcipher-dev
&&
rm
-rf
/var/lib/apt/lists/
*
# Check that library versions match (sqlcipher, libc, etc)
...
...
This diff is collapsed.
Click to expand it.
src/constants.rs
+
2
-
0
View file @
7224bb02
...
...
@@ -3,3 +3,5 @@
pub
const
DATABASE_DIR
:
&
str
=
"./data/db"
;
pub
const
MEDIA_DIR
:
&
str
=
"./data/media"
;
pub
const
SCHEMA_JSON_FILE
:
&
str
=
"../res/autogenerated_database_schema.json"
;
This diff is collapsed.
Click to expand it.
src/database_migrate_schema.rs
+
4
-
3
View file @
7224bb02
...
...
@@ -40,7 +40,10 @@ pub enum SchemaPropertyType {
lazy_static!
{
static
ref
SCHEMA_STRUCT
:
DatabaseSchema
=
{
let
schema
:
DatabaseSchema
=
serde_json
::
from_slice
(
SCHEMA_JSON_BYTES
)
let
file
=
crate
::
constants
::
SCHEMA_JSON_FILE
;
let
file
=
std
::
fs
::
read
(
file
)
.unwrap_or_else
(|
err
|
panic!
(
"Failed to read schema file {}, {}"
,
file
,
err
));
let
schema
:
DatabaseSchema
=
serde_json
::
from_slice
(
&
file
)
.expect
(
"Failed to parse autogenerated_database_schema to JSON"
);
validate_schema
(
&
schema
)
.unwrap_or_else
(|
err
|
panic!
(
"Schema validation failed, {}"
,
err
));
schema
...
...
@@ -103,8 +106,6 @@ lazy_static! {
};
}
const
SCHEMA_JSON_BYTES
:
&
[
u8
]
=
include_bytes!
(
"../res/autogenerated_database_schema.json"
);
pub
fn
migrate
(
conn
:
&
Connection
)
->
Result
<
(),
String
>
{
info!
(
"Initializing database schema (additional columns)"
);
let
schema
:
&
DatabaseSchema
=
&
SCHEMA_STRUCT
;
...
...
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