ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix column varchar lengths
Chocobozzz97c1ee00780e
diff --git a/server/core/initializers/constants.ts b/server/core/initializers/constants.tsindex 26e1f095e4..cd23e005e2 100644--- a/server/core/initializers/constants.ts+++ b/server/core/initializers/constants.ts@@ -62,7 +62,7 @@ import { CONFIG, registerConfigChangedHandler } from './config.js'// ----------------------------------------------------------------------------export const LAST_MIGRATION_VERSION = 1030+export const LAST_MIGRATION_VERSION = 1035// ---------------------------------------------------------------------------@@ -554,7 +554,7 @@ export const CONSTRAINTS_FIELDS = {WORD: { min: 1, max: 100 } // Length},VIDEO_VIEW: {- UA_INFO: { min: 1, max: 200 } // Length+ UA_INFO: { min: 1, max: 500 } // Length}}diff --git a/server/core/initializers/migrations/1035-varchar-lengths.ts b/server/core/initializers/migrations/1035-varchar-lengths.tsnew file mode 100644index 0000000000..b9e80706ca--- /dev/null+++ b/server/core/initializers/migrations/1035-varchar-lengths.ts@@ -0,0 +1,73 @@+import * as Sequelize from 'sequelize'++async function up (utils: {+ transaction: Sequelize.Transaction+ queryInterface: Sequelize.QueryInterface+ sequelize: Sequelize.Sequelize+}): Promise<void> {+ const { transaction } = utils++ await utils.sequelize.query(+ 'ALTER TABLE "plugin" ALTER COLUMN "description" TYPE VARCHAR(20000)',+ { transaction }+ )++ await utils.sequelize.query(+ 'ALTER TABLE "plugin" ALTER COLUMN "homepage" TYPE VARCHAR(2000)',+ { transaction }+ )++ await utils.sequelize.query(+ 'ALTER TABLE "runnerRegistrationToken" ALTER COLUMN "registrationToken" TYPE VARCHAR(1000)',+ { transaction }+ )++ await utils.sequelize.query(+ 'ALTER TABLE "runner" ALTER COLUMN "runnerToken" TYPE VARCHAR(1000)',+ { transaction }+ )++ await utils.sequelize.query(+ 'ALTER TABLE "runnerJob" ALTER COLUMN "processingJobToken" TYPE VARCHAR(1000)',+ { transaction }+ )++ await utils.sequelize.query(+ 'ALTER TABLE "localVideoViewer" ALTER COLUMN "url" TYPE VARCHAR(2000)',+ { transaction }+ )++ await utils.sequelize.query(+ 'ALTER TABLE "tracker" ALTER COLUMN "url" TYPE VARCHAR(2000)',+ { transaction }+ )++ await utils.sequelize.query(+ 'ALTER TABLE "uploadImage" ALTER COLUMN "fileUrl" TYPE VARCHAR(2000)',+ { transaction }+ )++ await utils.sequelize.query(+ 'ALTER TABLE "oAuthToken" ALTER COLUMN "loginDevice" TYPE VARCHAR(500)',+ { transaction }+ )++ await utils.sequelize.query(+ 'ALTER TABLE "oAuthToken" ALTER COLUMN "lastActivityDevice" TYPE VARCHAR(500)',+ { transaction }+ )++ await utils.sequelize.query(+ 'ALTER TABLE "localVideoViewer" ALTER COLUMN "client" TYPE VARCHAR(500)',+ { transaction }+ )+}++function down (options) {+ throw new Error('Not implemented.')+}++export {+ down,+ up+}diff --git a/server/core/models/application/upload-image.ts b/server/core/models/application/upload-image.tsindex 8ee4e89a2b..d91e22c12e 100644--- a/server/core/models/application/upload-image.ts+++ b/server/core/models/application/upload-image.ts@@ -3,9 +3,20 @@ import { MActorId, MUploadImage } from '@server/types/models/index.js'import { remove } from 'fs-extra/esm'import { join } from 'path'import { Transaction } from 'sequelize'-import { AfterDestroy, AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Table, UpdatedAt } from 'sequelize-typescript'+import {+ AfterDestroy,+ AllowNull,+ BelongsTo,+ Column,+ CreatedAt,+ DataType,+ Default,+ ForeignKey,+ Table,+ UpdatedAt+} from 'sequelize-typescript'import { logger } from '../../helpers/logger.js'-import { DIRECTORIES, STATIC_PATHS, WEBSERVER } from '../../initializers/constants.js'+import { CONSTRAINTS_FIELDS, DIRECTORIES, STATIC_PATHS, WEBSERVER } from '../../initializers/constants.js'import { ActorModel } from '../actor/actor.js'import { SequelizeModel } from '../shared/index.js'@@ -41,7 +52,7 @@ export class UploadImageModel extends SequelizeModel<UploadImageModel> {declare width: number@AllowNull(true)- @Column+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.COMMONS.URL.max))declare fileUrl: string@AllowNull(false)diff --git a/server/core/models/oauth/oauth-token.ts b/server/core/models/oauth/oauth-token.tsindex 6abb466131..0da8b8ba6d 100644--- a/server/core/models/oauth/oauth-token.ts+++ b/server/core/models/oauth/oauth-token.ts@@ -10,6 +10,7 @@ import {BelongsTo,Column,CreatedAt,+ DataType,ForeignKey,Scopes,Table,@@ -100,7 +101,7 @@ export class OAuthTokenModel extends SequelizeModel<OAuthTokenModel> {@Columndeclare authName: string- @Column+ @Column(DataType.STRING(500))declare loginDevice: string@Column@@ -109,7 +110,7 @@ export class OAuthTokenModel extends SequelizeModel<OAuthTokenModel> {@Columndeclare loginDate: Date- @Column+ @Column(DataType.STRING(500))declare lastActivityDevice: string@Columndiff --git a/server/core/models/runner/runner-job.ts b/server/core/models/runner/runner-job.tsindex 70068bda0c..1d5156326c 100644--- a/server/core/models/runner/runner-job.ts+++ b/server/core/models/runner/runner-job.ts@@ -107,7 +107,7 @@ export class RunnerJobModel extends SequelizeModel<RunnerJobModel> {// Used to fetch the appropriate job when the runner wants to post the result@AllowNull(true)- @Column+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.RUNNER_JOBS.TOKEN.max))declare processingJobToken: string@AllowNull(true)diff --git a/server/core/models/runner/runner-registration-token.ts b/server/core/models/runner/runner-registration-token.tsindex 7fa6c768df..b61d6fb92f 100644--- a/server/core/models/runner/runner-registration-token.ts+++ b/server/core/models/runner/runner-registration-token.ts@@ -1,5 +1,6 @@+import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js'import { FindOptions, literal } from 'sequelize'-import { AllowNull, Column, CreatedAt, HasMany, Table, UpdatedAt } from 'sequelize-typescript'+import { AllowNull, Column, CreatedAt, DataType, HasMany, Table, UpdatedAt } from 'sequelize-typescript'import { MRunnerRegistrationToken } from '@server/types/models/runners/index.js'import { RunnerRegistrationToken } from '@peertube/peertube-models'import { SequelizeModel, getSort } from '../shared/index.js'@@ -20,7 +21,7 @@ import { RunnerModel } from './runner.js'})export class RunnerRegistrationTokenModel extends SequelizeModel<RunnerRegistrationTokenModel> {@AllowNull(false)- @Column+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.RUNNERS.TOKEN.max))declare registrationToken: string@CreatedAtdiff --git a/server/core/models/runner/runner.ts b/server/core/models/runner/runner.tsindex ef4606e685..a76d984c96 100644--- a/server/core/models/runner/runner.ts+++ b/server/core/models/runner/runner.ts@@ -25,7 +25,7 @@ import { RunnerRegistrationTokenModel } from './runner-registration-token.js'export class RunnerModel extends SequelizeModel<RunnerModel> {// Used to identify the appropriate runner when it uses the runner REST API@AllowNull(false)- @Column+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.RUNNERS.TOKEN.max))declare runnerToken: string@AllowNull(false)diff --git a/server/core/models/server/plugin.ts b/server/core/models/server/plugin.tsindex 37ab0a7462..a8603cf9fb 100644--- a/server/core/models/server/plugin.ts+++ b/server/core/models/server/plugin.ts@@ -17,6 +17,7 @@ import {isPluginTypeValid} from '../../helpers/custom-validators/plugins.js'import { SequelizeModel, getSort, throwIfNotValid } from '../shared/index.js'+import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js'@DefaultScope(() => ({attributes: {@@ -67,12 +68,12 @@ export class PluginModel extends SequelizeModel<PluginModel> {@AllowNull(true)@Is('PluginDescription', value => throwIfNotValid(value, isPluginDescriptionValid, 'description'))- @Column+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.PLUGINS.DESCRIPTION.max))declare description: string@AllowNull(false)@Is('PluginHomepage', value => throwIfNotValid(value, isPluginHomepage, 'homepage'))- @Column+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.COMMONS.URL.max))declare homepage: string@AllowNull(true)diff --git a/server/core/models/server/tracker.ts b/server/core/models/server/tracker.tsindex 0f00b52a9a..9d9d049087 100644--- a/server/core/models/server/tracker.ts+++ b/server/core/models/server/tracker.ts@@ -1,4 +1,5 @@-import { AllowNull, BelongsToMany, Column, CreatedAt, Table, UpdatedAt } from 'sequelize-typescript'+import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js'+import { AllowNull, BelongsToMany, Column, CreatedAt, DataType, Table, UpdatedAt } from 'sequelize-typescript'import { Transaction } from 'sequelize'import { MTracker } from '@server/types/models/server/tracker.js'import { VideoModel } from '../video/video.js'@@ -16,7 +17,7 @@ import { SequelizeModel } from '../shared/sequelize-type.js'})export class TrackerModel extends SequelizeModel<TrackerModel> {@AllowNull(false)- @Column+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.COMMONS.URL.max))declare url: string@CreatedAtdiff --git a/server/core/models/stat/local-video-viewer.ts b/server/core/models/stat/local-video-viewer.tsindex 1b8a57f038..05790b5730 100644--- a/server/core/models/stat/local-video-viewer.ts+++ b/server/core/models/stat/local-video-viewer.ts@@ -6,7 +6,7 @@ import {VideoStatsUserAgent,WatchActionObject} from '@peertube/peertube-models'-import { MAX_SQL_DELETE_ITEMS } from '@server/initializers/constants.js'+import { CONSTRAINTS_FIELDS, MAX_SQL_DELETE_ITEMS } from '@server/initializers/constants.js'import { getActivityStreamDuration } from '@server/lib/activitypub/activity.js'import { buildGroupByAndBoundaries } from '@server/lib/timeserie.js'import { MLocalVideoViewer, MLocalVideoViewerWithWatchSections, MVideo } from '@server/types/models/index.js'@@ -51,7 +51,7 @@ export class LocalVideoViewerModel extends SequelizeModel<LocalVideoViewerModel>declare watchTime: number@AllowNull(true)- @Column+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_VIEW.UA_INFO.max))declare client: string@AllowNull(true)@@ -77,7 +77,7 @@ export class LocalVideoViewerModel extends SequelizeModel<LocalVideoViewerModel>declare uuid: string@AllowNull(false)- @Column+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.COMMONS.URL.max))declare url: string@ForeignKey(() => VideoModel)diff --git a/server/core/models/video/video-live.ts b/server/core/models/video/video-live.tsindex 47cdefe43f..0b724d72c2 100644--- a/server/core/models/video/video-live.ts+++ b/server/core/models/video/video-live.ts@@ -7,18 +7,7 @@ import {MVideoLiveWithSettingSchedules} from '@server/types/models/index.js'import { Transaction } from 'sequelize'-import {- AllowNull,- BeforeDestroy,- BelongsTo,- Column,- CreatedAt,- DataType,- ForeignKey,- HasMany,- Table,- UpdatedAt-} from 'sequelize-typescript'+import { AllowNull, BeforeDestroy, BelongsTo, Column, CreatedAt, ForeignKey, HasMany, Table, UpdatedAt } from 'sequelize-typescript'import { SequelizeModel } from '../shared/index.js'import { VideoBlacklistModel } from './video-blacklist.js'import { VideoLiveReplaySettingModel } from './video-live-replay-setting.js'@@ -40,7 +29,7 @@ import { VideoModel } from './video.js'})export class VideoLiveModel extends SequelizeModel<VideoLiveModel> {@AllowNull(true)- @Column(DataType.STRING)+ @Columndeclare streamKey: string@AllowNull(false)