Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public List<IItem> list(SclFileType type) {
from (select distinct on (scl_file.id) *
from scl_file
where scl_file.type = ?
AND scl_file.is_deleted = false
order by scl_file.id
, scl_file.major_version desc
, scl_file.minor_version desc
Expand Down Expand Up @@ -115,6 +116,7 @@ left outer join (
and scl_data.patch_version = scl_file.patch_version
where scl_file.id = ?
and scl_file.type = ?
and scl_file.is_deleted = false
order by scl_file.major_version
, scl_file.minor_version
, scl_file.patch_version
Expand Down Expand Up @@ -162,6 +164,7 @@ public String findByUUID(SclFileType type, UUID id, Version version) {
and scl_file.major_version = ?
and scl_file.minor_version = ?
and scl_file.patch_version = ?
and scl_file.is_deleted = false
""";

try (var connection = dataSource.getConnection();
Expand Down Expand Up @@ -191,6 +194,7 @@ public boolean hasDuplicateSclName(SclFileType type, String name) {
select distinct on (scl_file.id) scl_file.name
from scl_file
where scl_file.type = ?
and scl_file.is_deleted = false
order by scl_file.id
, scl_file.major_version desc
, scl_file.minor_version desc
Expand Down Expand Up @@ -221,6 +225,7 @@ public IAbstractItem findMetaInfoByUUID(SclFileType type, UUID id) {
from scl_file
where scl_file.id = ?
and scl_file.type = ?
and scl_file.is_deleted = false
order by scl_file.major_version desc, scl_file.minor_version desc, scl_file.patch_version desc
""";

Expand Down Expand Up @@ -305,7 +310,8 @@ insert into scl_label(scl_id, major_version, minor_version, patch_version, label
@Transactional(REQUIRED)
public void delete(SclFileType type, UUID id) {
var sql = """
delete from scl_file
UPDATE scl_file
SET scl_file.is_deleted = false
where scl_file.id = ?
and scl_file.type = ?
""";
Expand All @@ -324,7 +330,8 @@ public void delete(SclFileType type, UUID id) {
@Transactional(REQUIRED)
public void delete(SclFileType type, UUID id, Version version) {
var sql = """
delete from scl_file
UPDATE scl_file
SET scl_file.is_deleted = false
where scl_file.id = ?
and scl_file.type = ?
and scl_file.major_version = ?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* SPDX-FileCopyrightText: 2021 Alliander N.V.
*
* SPDX-License-Identifier: Apache-2.0
*/

--
-- Update SCL File Table to add soft deletion
--

ALTER TABLE scl_file
ADD COLUMN is_deleted BOOLEAN DEFAULT false;

comment on column scl_file.is_deleted is 'Flag is the SCL File is deleted.';
Loading