Skip to content

Commit 69c5254

Browse files
committed
feat(ydbcp): make db schema initialization and migration via goose
1 parent c5f7b99 commit 69c5254

File tree

5 files changed

+28
-23
lines changed

5 files changed

+28
-23
lines changed

init_db/create_tables.sh renamed to cmd/integration/scripts/create_test_tables.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# create ydbcp tables
2-
./ydb -e ${YDB_ENDPOINT} -d /local scripting yql -f init_db/schema/create_tables.yql
3-
41
# create and fill user table kv_test
52
./ydb -e ${YDB_ENDPOINT} -d /local workload kv init
63
./ydb -e ${YDB_ENDPOINT} -d /local workload kv run upsert --rows 100

internal/connectors/db/yql/schema/drop_tables.yql

Lines changed: 0 additions & 3 deletions
This file was deleted.

internal/connectors/db/yql/schema/fill_tables.yql

Lines changed: 0 additions & 14 deletions
This file was deleted.

internal/connectors/db/yql/schema/create_tables.yql renamed to migrations/yql/20251126000000_init_schema.sql

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
-- +goose Up
12
CREATE TABLE Backups (
23
id String NOT NULL,
34
container_id String NOT NULL,
@@ -51,7 +52,6 @@ CREATE TABLE Operations (
5152
status String,
5253
message String,
5354

54-
root_path String,
5555
paths String,
5656
paths_to_exclude String,
5757
operation_id String,
@@ -80,7 +80,6 @@ CREATE TABLE BackupSchedules (
8080

8181
crontab String NOT NULL,
8282
ttl Interval,
83-
root_path String,
8483
paths String,
8584
paths_to_exclude String,
8685

@@ -91,4 +90,16 @@ CREATE TABLE BackupSchedules (
9190

9291
next_launch Timestamp,
9392
PRIMARY KEY (id)
94-
)
93+
);
94+
95+
UPSERT INTO OperationTypes (code, description, is_cancellable) VALUES
96+
('TB', 'Take backup', True),
97+
('RB', 'Restore backup', True),
98+
('RM', 'Remove backup', False);
99+
100+
-- +goose Down
101+
DROP TABLE BackupSchedules;
102+
DROP TABLE Operations;
103+
DROP TABLE OperationTypes;
104+
DROP TABLE Backups;
105+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- +goose Up
2+
ALTER TABLE Operations
3+
ADD COLUMN root_path String;
4+
5+
ALTER TABLE BackupSchedules
6+
ADD COLUMN root_path String;
7+
8+
-- +goose Down
9+
ALTER TABLE BackupSchedules
10+
DROP COLUMN root_path;
11+
12+
ALTER TABLE Operations
13+
DROP COLUMN root_path;
14+

0 commit comments

Comments
 (0)