Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
document-storage
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wandelwerk-Software
libraries
document-storage
Commits
85910ced
Commit
85910ced
authored
2 years ago
by
Bruno Burke
Browse files
Options
Downloads
Patches
Plain Diff
add changelog and activate versioning for postgres
parent
46b7adb1
Branches
master
No related tags found
No related merge requests found
Pipeline
#134680
passed
2 years ago
Stage: build
Stage: test
Stage: visualize
Stage: deploy
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG
+8
-0
8 additions, 0 deletions
CHANGELOG
project.clj
+1
-1
1 addition, 1 deletion
project.clj
resources/sql/_ds_postgres.sql
+10
-1
10 additions, 1 deletion
resources/sql/_ds_postgres.sql
src/document_storage/postgres/documents.clj
+19
-3
19 additions, 3 deletions
src/document_storage/postgres/documents.clj
with
38 additions
and
5 deletions
CHANGELOG
0 → 100644
+
8
−
0
View file @
85910ced
# Changelog
Hier werden alle Änderungen dokumentiert.
### 2023-01-27 - version 0.3.0
## Fixed
- versioning can now be turned off in postgres-storage. An existing last frame/version will be overwritten with a keyframe if versioning is turned off.
This diff is collapsed.
Click to expand it.
project.clj
+
1
−
1
View file @
85910ced
(
defproject
wwsoftware/document-storage
"0.
2.9
"
(
defproject
wwsoftware/document-storage
"0.
3.0
"
:description
"FIXME: write description"
:repositories
[[
"internal"
{
:url
"https://maven.leukipp.de/releases"
:username
"anonymous"
}]]
...
...
This diff is collapsed.
Click to expand it.
resources/sql/_ds_postgres.sql
+
10
−
1
View file @
85910ced
...
...
@@ -44,10 +44,19 @@ SELECT document_id
-- :doc creates a new document frame record
INSERT
INTO
:
i
:
repository
-
table
(
document_id
,
data_type
,
data_encoding
,
version
,
reference
,
"data"
)
VALUES
(:
document
-
id
,
CAST
(:
type
::
varchar
AS
:
i
:
ds
-
type
-
fqn
),
CAST
(:
encoding
::
varchar
AS
:
i
:
ds
-
encoding
-
fqn
),
:
version
,
:
reference
,
:
data
)
VALUES
(:
document
-
id
,
CAST
(:
type
::
varchar
AS
:
i
:
ds
-
type
-
fqn
),
CAST
(:
encoding
::
varchar
AS
:
i
:
ds
-
encoding
-
fqn
),
:
version
,
:
reference
,
:
data
)
;
--;; TODO type cast is problematic with multiple storage schemas in one database
-- :name overwrite-document-frame! :! :n
-- :doc overwrite a document frame record given the version
UPDATE
:
i
:
repository
-
table
SET
data_type
=
CAST
(:
type
::
varchar
AS
:
i
:
ds
-
type
-
fqn
),
data_encoding
=
CAST
(:
encoding
::
varchar
AS
:
i
:
ds
-
encoding
-
fqn
),
reference
=
:
reference
,
"data"
=
:
data
WHERE
document_id
=
:
document
-
id
AND
version
=
:
version
;
-- :name get-last-document-frame :? :1
-- :doc retrieve the last document-frame given the document-id.
SELECT
*
FROM
:
i
:
repository
-
table
WHERE
document_id
=
:
document
-
id
order
by
"version"
desc
limit
1
...
...
This diff is collapsed.
Click to expand it.
src/document_storage/postgres/documents.clj
+
19
−
3
View file @
85910ced
...
...
@@ -19,8 +19,8 @@
(
defn
get-last-document-frame
[
storage
document-id
repository
]
;;;TODO check if this can be speed up by using index in db
(
when-let
[
frame
(
.run-query
storage
:get-last-document-frame
{
:repository
repository
:document-id
document-id
})]
{
:repository
repository
:document-id
document-id
})]
frame
))
(
defn
get-last-document-version
[
storage
document-id
repository
]
...
...
@@ -74,6 +74,18 @@
:reference
nil
:data
doc
})))
(
defn
overwrite-keyframe
[
storage
document-id
document
version
repository
]
(
let
[
doc
(
encoding/encode-document
document
)
version
(
or
version
0
)]
;;VALUES (:uuid, :document-id, :type, :encoding, :version, :reference, :data)
(
.run-query
storage
:overwrite-document-frame!
{
:repository
repository
:document-id
document-id
:type
"key"
:encoding
"nippy"
:version
version
:reference
nil
:data
doc
})))
(
defn
save-pframe
[
storage
document-id
doc
last-version
repository
]
(
let
[
last-doc
(
load-document
storage
document-id
last-version
repository
)
...
...
@@ -99,8 +111,12 @@
(
cache/update-query-cache-document
storage
repository
document-id
document
)
(
let
[
save-result
(
if-let
[
last-version
(
get-last-document-version
storage
document-id
repository
)]
(
if
(
or
(
true?
(
:force-keyframe
options
))
(
false?
(
.versioned-repository?
storage
repository
))
(
=
(
:data-type
last-version
)
:delete
))
(
save-keyframe
storage
document-id
document
(
:version
last-version
)
repository
)
(
let
[
version-num
(
:version
last-version
)]
(
if
(
.versioned-repository?
storage
repository
)
(
save-keyframe
storage
document-id
document
version-num
repository
)
(
overwrite-keyframe
storage
document-id
document
version-num
repository
)))
(
save-pframe
storage
document-id
document
(
:version
last-version
)
repository
))
(
save-keyframe
storage
document-id
document
-1
repository
))]
(
.take
queue
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment