Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data export migration #223

Merged
merged 22 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c5ea22d
Add data export migration
sjorobekov Dec 19, 2024
b246333
add DataExport model
sjorobekov Dec 20, 2024
08a031b
add indices in DataExport
sjorobekov Dec 26, 2024
b6b083f
Add data export migration
sjorobekov Dec 27, 2024
28de5bd
Merge branch 'main' of github.com:datalens-tech/datalens-us into CHAR…
sjorobekov Dec 27, 2024
f359b2e
add DataExport model
sjorobekov Dec 27, 2024
e024502
Add data export migration
sjorobekov Dec 28, 2024
cb50c77
Merge branch 'main' of github.com:datalens-tech/datalens-us into CHAR…
sjorobekov Jan 10, 2025
58f2261
cleanup DataExport model
sjorobekov Jan 14, 2025
7a24ed2
Merge branch 'main' of github.com:datalens-tech/datalens-us into CHAR…
sjorobekov Jan 14, 2025
0d8baf4
Merge branch 'main' of github.com:datalens-tech/datalens-us into CHAR…
sjorobekov Jan 15, 2025
5a452b3
replace Nullable by Optional in dataExport.datasetId
sjorobekov Jan 15, 2025
60081f8
Merge branch 'main' of github.com:datalens-tech/datalens-us into CHAR…
sjorobekov Jan 16, 2025
20b7da5
Merge branch 'main' of github.com:datalens-tech/datalens-us into CHAR…
sjorobekov Jan 17, 2025
85d3383
Merge branch 'main' of github.com:datalens-tech/datalens-us into CHAR…
sjorobekov Jan 20, 2025
3ddea35
Add data export migration
sjorobekov Jan 20, 2025
5d85cdc
Merge branch 'main' of github.com:datalens-tech/datalens-us into CHAR…
sjorobekov Jan 20, 2025
40eb7c9
Add data export migration
sjorobekov Jan 20, 2025
59e663f
Merge branch 'main' of github.com:datalens-tech/datalens-us into CHAR…
sjorobekov Jan 21, 2025
1fe66b4
Add data export migration
sjorobekov Jan 21, 2025
b71685a
Add data export migration
sjorobekov Jan 21, 2025
c141140
Add data export migration
sjorobekov Jan 21, 2025
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
2 changes: 1 addition & 1 deletion api/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export {Lock} from '../src/db/models/new/lock';
export {Favorite} from '../src/db/models/new/favorite';
export {UserSettings} from '../src/db/models/new/user-settings';
export {Comment, CommentType} from '../src/db/models/new/comment';

export {DataExport} from '../src/db/models/new/data-export';
export {EmbedModel, EmbedModelColumn} from '../src/db/models/new/embed';
export {
EmbeddingSecretModel,
Expand Down
42 changes: 42 additions & 0 deletions src/db/migrations/20241219092946_data_export.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type {Knex} from 'knex';

export async function up(knex: Knex): Promise<void> {
return knex.raw(`
CREATE TABLE data_exports (
data_export_id BIGINT NOT NULL PRIMARY KEY DEFAULT get_id(),
title TEXT NOT NULL,
tenant_id TEXT NOT NULL DEFAULT 'common' REFERENCES tenants (tenant_id) ON UPDATE CASCADE ON DELETE CASCADE,
chart_id BIGINT REFERENCES entries (entry_id) ON UPDATE CASCADE ON DELETE SET NULL,
imsitnikov marked this conversation as resolved.
Show resolved Hide resolved
chart_rev_id BIGINT REFERENCES revisions (rev_id) ON UPDATE CASCADE ON DELETE SET NULL,
dataset_id BIGINT REFERENCES entries (entry_id) ON UPDATE CASCADE ON DELETE SET NULL,
dataset_rev_id BIGINT REFERENCES revisions (rev_id) ON UPDATE CASCADE ON DELETE SET NULL,
connection_id BIGINT REFERENCES entries (entry_id) ON UPDATE CASCADE ON DELETE SET NULL,
connection_rev_id BIGINT REFERENCES revisions (rev_id) ON UPDATE CASCADE ON DELETE SET NULL,
params JSONB NOT NULL DEFAULT '{}'::jsonb,
created_by TEXT NOT NULL,
updated_by TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ,
expired_at TIMESTAMPTZ NOT NULL,
job_id TEXT NOT NULL,
result_link TEXT,
error JSONB
);

CREATE INDEX data_exports_chart_id_idx ON data_exports(chart_id);
CREATE INDEX data_exports_dataset_id_idx ON data_exports(dataset_id);
CREATE INDEX data_exports_connection_id_idx ON data_exports(connection_id);
CREATE INDEX data_exports_expired_at_idx ON data_exports(expired_at);
`);
}

export async function down(knex: Knex): Promise<void> {
return knex.raw(`
DROP INDEX data_exports_chart_id_idx;
DROP INDEX data_exports_dataset_id_idx;
DROP INDEX data_exports_connection_id_idx;
DROP INDEX data_exports_expired_at_idx;

DROP TABLE data_exports;
`);
}
30 changes: 30 additions & 0 deletions src/db/models/new/data-export/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {Model} from '../../..';

export class DataExport extends Model {
static get tableName() {
return 'data_exports';
}

static get idColumn() {
return 'dataExportId';
}

dataExportId!: string;
title!: string;
tenantId!: string;
chartId!: Nullable<string>;
chartRevId!: Nullable<string>;
datasetId!: Nullable<string>;
datasetRevId!: Nullable<string>;
connectionId!: Nullable<string>;
connectionRevId!: Nullable<string>;
params!: Record<string, unknown>;
createdBy!: string;
updatedBy!: Nullable<string>;
createdAt!: string;
updatedAt!: Nullable<string>;
expiredAt!: string;
jobId!: string;
resultLink!: Nullable<string>;
error!: Nullable<Record<string, unknown>>;
}
Loading