From 99ec0b71161f7db387d8d9e8f895cd2848bf930c Mon Sep 17 00:00:00 2001 From: Nutomic Date: Tue, 24 Jun 2025 14:21:50 +0000 Subject: [PATCH] Rename rate limit columns (fixes #5805) (#5824) * Rename rate limit columns (fixes #5805) * update js client --- api_tests/package.json | 2 +- api_tests/pnpm-lock.yaml | 10 +-- api_tests/src/shared.ts | 12 +-- crates/api/api_crud/src/site/create.rs | 30 ++++--- crates/api/api_crud/src/site/update.rs | 30 ++++--- crates/api/api_utils/src/utils.rs | 20 ++--- .../src/impls/local_site_rate_limit.rs | 24 +++--- .../src/source/local_site_rate_limit.rs | 84 +++++++++---------- crates/db_schema_file/src/schema.rs | 29 +++---- crates/db_views/site/src/api.rs | 53 ++++++------ crates/utils/src/rate_limit.rs | 36 ++++---- .../down.sql | 28 +++++++ .../up.sql | 28 +++++++ 13 files changed, 228 insertions(+), 158 deletions(-) create mode 100644 migrations/2025-06-24-093800_rename-rate-limit-columns/down.sql create mode 100644 migrations/2025-06-24-093800_rename-rate-limit-columns/up.sql diff --git a/api_tests/package.json b/api_tests/package.json index fe7a80c3b..c9f093045 100644 --- a/api_tests/package.json +++ b/api_tests/package.json @@ -31,7 +31,7 @@ "eslint-plugin-prettier": "^5.4.0", "jest": "^29.5.0", "joi": "^17.13.3", - "lemmy-js-client": "1.0.0-dont-return-actions.1", + "lemmy-js-client": "1.0.0-rename-rate-limit-columns.1", "prettier": "^3.5.3", "ts-jest": "^29.3.2", "tsoa": "^6.6.0", diff --git a/api_tests/pnpm-lock.yaml b/api_tests/pnpm-lock.yaml index d962c3c48..e834f72c7 100644 --- a/api_tests/pnpm-lock.yaml +++ b/api_tests/pnpm-lock.yaml @@ -36,8 +36,8 @@ importers: specifier: ^17.13.3 version: 17.13.3 lemmy-js-client: - specifier: 1.0.0-dont-return-actions.1 - version: 1.0.0-dont-return-actions.1 + specifier: 1.0.0-rename-rate-limit-columns.1 + version: 1.0.0-rename-rate-limit-columns.1 prettier: specifier: ^3.5.3 version: 3.5.3 @@ -1594,8 +1594,8 @@ packages: resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} engines: {node: '>=6'} - lemmy-js-client@1.0.0-dont-return-actions.1: - resolution: {integrity: sha512-1eiLU+0ZBOqu//p2CRrO8hOTJbOWgpNYAB/R9I4sjuunp6i0oIzMhXNTg7hW8hQ8fyG7YO2BrgQQu861ZchnDg==} + lemmy-js-client@1.0.0-rename-rate-limit-columns.1: + resolution: {integrity: sha512-zlVJ4zkoI/7hNm6x7vr+Su2cRjAr8PQCA9j0GeK1UCMEIBLLSltknuRPC79VJY2sUhRAuR2JwTR0JtZ75SH2XQ==} leven@3.1.0: resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} @@ -4404,7 +4404,7 @@ snapshots: kleur@3.0.3: {} - lemmy-js-client@1.0.0-dont-return-actions.1: + lemmy-js-client@1.0.0-rename-rate-limit-columns.1: dependencies: '@tsoa/runtime': 6.6.0 transitivePeerDependencies: diff --git a/api_tests/src/shared.ts b/api_tests/src/shared.ts index 59c144960..baa58d21e 100644 --- a/api_tests/src/shared.ts +++ b/api_tests/src/shared.ts @@ -159,12 +159,12 @@ export async function setupLogins() { // Registration applications are now enabled by default, need to disable them let editSiteForm: EditSite = { registration_mode: "Open", - rate_limit_message: 999, - rate_limit_post: 999, - rate_limit_comment: 999, - rate_limit_register: 999, - rate_limit_search: 999, - rate_limit_image: 999, + rate_limit_message_max_requests: 999, + rate_limit_post_max_requests: 999, + rate_limit_comment_max_requests: 999, + rate_limit_register_max_requests: 999, + rate_limit_search_max_requests: 999, + rate_limit_image_max_requests: 999, }; await alpha.editSite(editSiteForm); await beta.editSite(editSiteForm); diff --git a/crates/api/api_crud/src/site/create.rs b/crates/api/api_crud/src/site/create.rs index 64dab15c5..06e62b9b0 100644 --- a/crates/api/api_crud/src/site/create.rs +++ b/crates/api/api_crud/src/site/create.rs @@ -114,19 +114,23 @@ pub async fn create_site( LocalSite::update(&mut context.pool(), &local_site_form).await?; let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm { - message: data.rate_limit_message, - message_per_second: not_zero(data.rate_limit_message_per_second), - post: data.rate_limit_post, - post_per_second: not_zero(data.rate_limit_post_per_second), - register: data.rate_limit_register, - register_per_second: not_zero(data.rate_limit_register_per_second), - image: data.rate_limit_image, - image_per_second: not_zero(data.rate_limit_image_per_second), - comment: data.rate_limit_comment, - comment_per_second: not_zero(data.rate_limit_comment_per_second), - search: data.rate_limit_search, - search_per_second: not_zero(data.rate_limit_search_per_second), - ..Default::default() + message_max_requests: data.rate_limit_message_max_requests, + message_interval_seconds: not_zero(data.rate_limit_message_interval_seconds), + post_max_requests: data.rate_limit_post_max_requests, + post_interval_seconds: not_zero(data.rate_limit_post_interval_seconds), + register_max_requests: data.rate_limit_register_max_requests, + register_interval_seconds: not_zero(data.rate_limit_register_interval_seconds), + image_max_requests: data.rate_limit_image_max_requests, + image_interval_seconds: not_zero(data.rate_limit_image_interval_seconds), + comment_max_requests: data.rate_limit_comment_max_requests, + comment_interval_seconds: not_zero(data.rate_limit_comment_interval_seconds), + search_max_requests: data.rate_limit_search_max_requests, + search_interval_seconds: not_zero(data.rate_limit_search_interval_seconds), + import_user_settings_max_requests: data.rate_limit_import_user_settings_max_requests, + import_user_settings_interval_seconds: not_zero( + data.rate_limit_import_user_settings_interval_seconds, + ), + updated_at: Some(Some(Utc::now())), }; LocalSiteRateLimit::update(&mut context.pool(), &local_site_rate_limit_form).await?; diff --git a/crates/api/api_crud/src/site/update.rs b/crates/api/api_crud/src/site/update.rs index 390731b2f..ac653eb09 100644 --- a/crates/api/api_crud/src/site/update.rs +++ b/crates/api/api_crud/src/site/update.rs @@ -125,19 +125,23 @@ pub async fn update_site( .ok(); let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm { - message: data.rate_limit_message, - message_per_second: not_zero(data.rate_limit_message_per_second), - post: data.rate_limit_post, - post_per_second: not_zero(data.rate_limit_post_per_second), - register: data.rate_limit_register, - register_per_second: not_zero(data.rate_limit_register_per_second), - image: data.rate_limit_image, - image_per_second: not_zero(data.rate_limit_image_per_second), - comment: data.rate_limit_comment, - comment_per_second: not_zero(data.rate_limit_comment_per_second), - search: data.rate_limit_search, - search_per_second: not_zero(data.rate_limit_search_per_second), - ..Default::default() + message_max_requests: data.rate_limit_message_max_requests, + message_interval_seconds: not_zero(data.rate_limit_message_interval_seconds), + post_max_requests: data.rate_limit_post_max_requests, + post_interval_seconds: not_zero(data.rate_limit_post_interval_seconds), + register_max_requests: data.rate_limit_register_max_requests, + register_interval_seconds: not_zero(data.rate_limit_register_interval_seconds), + image_max_requests: data.rate_limit_image_max_requests, + image_interval_seconds: not_zero(data.rate_limit_image_interval_seconds), + comment_max_requests: data.rate_limit_comment_max_requests, + comment_interval_seconds: not_zero(data.rate_limit_comment_interval_seconds), + search_max_requests: data.rate_limit_search_max_requests, + search_interval_seconds: not_zero(data.rate_limit_search_interval_seconds), + import_user_settings_max_requests: data.rate_limit_import_user_settings_max_requests, + import_user_settings_interval_seconds: not_zero( + data.rate_limit_import_user_settings_interval_seconds, + ), + updated_at: Some(Some(Utc::now())), }; LocalSiteRateLimit::update(&mut context.pool(), &local_site_rate_limit_form) diff --git a/crates/api/api_utils/src/utils.rs b/crates/api/api_utils/src/utils.rs index c0f7a4def..f3bee60cb 100644 --- a/crates/api/api_utils/src/utils.rs +++ b/crates/api/api_utils/src/utils.rs @@ -449,17 +449,17 @@ pub fn local_site_rate_limit_to_rate_limit_config( l: &LocalSiteRateLimit, ) -> EnumMap { enum_map! { - ActionType::Message => (l.message, l.message_per_second), - ActionType::Post => (l.post, l.post_per_second), - ActionType::Register => (l.register, l.register_per_second), - ActionType::Image => (l.image, l.image_per_second), - ActionType::Comment => (l.comment, l.comment_per_second), - ActionType::Search => (l.search, l.search_per_second), - ActionType::ImportUserSettings => (l.import_user_settings, l.import_user_settings_per_second), + ActionType::Message => (l.message_max_requests, l.message_interval_seconds), + ActionType::Post => (l.post_max_requests, l.post_interval_seconds), + ActionType::Register => (l.register_max_requests, l.register_interval_seconds), + ActionType::Image => (l.image_max_requests, l.image_interval_seconds), + ActionType::Comment => (l.comment_max_requests, l.comment_interval_seconds), + ActionType::Search => (l.search_max_requests, l.search_interval_seconds), + ActionType::ImportUserSettings => (l.import_user_settings_max_requests, l.import_user_settings_interval_seconds), } - .map(|_key, (capacity, secs_to_refill)| BucketConfig { - capacity: u32::try_from(capacity).unwrap_or(0), - secs_to_refill: u32::try_from(secs_to_refill).unwrap_or(0), + .map(|_key, (max_requests, interval)| BucketConfig { + max_requests: u32::try_from(max_requests).unwrap_or(0), + interval: u32::try_from(interval).unwrap_or(0), }) } diff --git a/crates/db_schema/src/impls/local_site_rate_limit.rs b/crates/db_schema/src/impls/local_site_rate_limit.rs index de8d31899..323f43835 100644 --- a/crates/db_schema/src/impls/local_site_rate_limit.rs +++ b/crates/db_schema/src/impls/local_site_rate_limit.rs @@ -52,18 +52,18 @@ impl LocalSiteRateLimit { impl LocalSiteRateLimitUpdateForm { fn is_empty(&self) -> bool { - self.message.is_none() - && self.message_per_second.is_none() - && self.post.is_none() - && self.post_per_second.is_none() - && self.register.is_none() - && self.register_per_second.is_none() - && self.image.is_none() - && self.image_per_second.is_none() - && self.comment.is_none() - && self.comment_per_second.is_none() - && self.search.is_none() - && self.search_per_second.is_none() + self.message_max_requests.is_none() + && self.message_interval_seconds.is_none() + && self.post_max_requests.is_none() + && self.post_interval_seconds.is_none() + && self.register_max_requests.is_none() + && self.register_interval_seconds.is_none() + && self.image_max_requests.is_none() + && self.image_interval_seconds.is_none() + && self.comment_max_requests.is_none() + && self.comment_interval_seconds.is_none() + && self.search_max_requests.is_none() + && self.search_interval_seconds.is_none() && self.updated_at.is_none() } } diff --git a/crates/db_schema/src/source/local_site_rate_limit.rs b/crates/db_schema/src/source/local_site_rate_limit.rs index 85ab2b984..bbc077d06 100644 --- a/crates/db_schema/src/source/local_site_rate_limit.rs +++ b/crates/db_schema/src/source/local_site_rate_limit.rs @@ -20,22 +20,22 @@ use serde_with::skip_serializing_none; /// Rate limits for your site. Given in count / length of time. pub struct LocalSiteRateLimit { pub local_site_id: LocalSiteId, - pub message: i32, - pub message_per_second: i32, - pub post: i32, - pub post_per_second: i32, - pub register: i32, - pub register_per_second: i32, - pub image: i32, - pub image_per_second: i32, - pub comment: i32, - pub comment_per_second: i32, - pub search: i32, - pub search_per_second: i32, + pub message_max_requests: i32, + pub message_interval_seconds: i32, + pub post_max_requests: i32, + pub post_interval_seconds: i32, + pub register_max_requests: i32, + pub register_interval_seconds: i32, + pub image_max_requests: i32, + pub image_interval_seconds: i32, + pub comment_max_requests: i32, + pub comment_interval_seconds: i32, + pub search_max_requests: i32, + pub search_interval_seconds: i32, pub published_at: DateTime, pub updated_at: Option>, - pub import_user_settings: i32, - pub import_user_settings_per_second: i32, + pub import_user_settings_max_requests: i32, + pub import_user_settings_interval_seconds: i32, } #[derive(Clone, derive_new::new)] @@ -44,52 +44,52 @@ pub struct LocalSiteRateLimit { pub struct LocalSiteRateLimitInsertForm { pub local_site_id: LocalSiteId, #[new(default)] - pub message: Option, + pub message_max_requests: Option, #[new(default)] - pub message_per_second: Option, + pub message_interval_seconds: Option, #[new(default)] - pub post: Option, + pub post_max_requests: Option, #[new(default)] - pub post_per_second: Option, + pub post_interval_seconds: Option, #[new(default)] - pub register: Option, + pub register_max_requests: Option, #[new(default)] - pub register_per_second: Option, + pub register_interval_seconds: Option, #[new(default)] - pub image: Option, + pub image_max_requests: Option, #[new(default)] - pub image_per_second: Option, + pub image_interval_seconds: Option, #[new(default)] - pub comment: Option, + pub comment_max_requests: Option, #[new(default)] - pub comment_per_second: Option, + pub comment_interval_seconds: Option, #[new(default)] - pub search: Option, + pub search_max_requests: Option, #[new(default)] - pub search_per_second: Option, + pub search_interval_seconds: Option, #[new(default)] - pub import_user_settings: Option, + pub import_user_settings_max_requests: Option, #[new(default)] - pub import_user_settings_per_second: Option, + pub import_user_settings_interval_seconds: Option, } #[derive(Clone, Default)] #[cfg_attr(feature = "full", derive(AsChangeset))] #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))] pub struct LocalSiteRateLimitUpdateForm { - pub message: Option, - pub message_per_second: Option, - pub post: Option, - pub post_per_second: Option, - pub register: Option, - pub register_per_second: Option, - pub image: Option, - pub image_per_second: Option, - pub comment: Option, - pub comment_per_second: Option, - pub search: Option, - pub search_per_second: Option, - pub import_user_settings: Option, - pub import_user_settings_per_second: Option, + pub message_max_requests: Option, + pub message_interval_seconds: Option, + pub post_max_requests: Option, + pub post_interval_seconds: Option, + pub register_max_requests: Option, + pub register_interval_seconds: Option, + pub image_max_requests: Option, + pub image_interval_seconds: Option, + pub comment_max_requests: Option, + pub comment_interval_seconds: Option, + pub search_max_requests: Option, + pub search_interval_seconds: Option, + pub import_user_settings_max_requests: Option, + pub import_user_settings_interval_seconds: Option, pub updated_at: Option>>, } diff --git a/crates/db_schema_file/src/schema.rs b/crates/db_schema_file/src/schema.rs index 5ef496f18..da910ea90 100644 --- a/crates/db_schema_file/src/schema.rs +++ b/crates/db_schema_file/src/schema.rs @@ -459,22 +459,22 @@ diesel::table! { diesel::table! { local_site_rate_limit (local_site_id) { local_site_id -> Int4, - message -> Int4, - message_per_second -> Int4, - post -> Int4, - post_per_second -> Int4, - register -> Int4, - register_per_second -> Int4, - image -> Int4, - image_per_second -> Int4, - comment -> Int4, - comment_per_second -> Int4, - search -> Int4, - search_per_second -> Int4, + message_max_requests -> Int4, + message_interval_seconds -> Int4, + post_max_requests -> Int4, + post_interval_seconds -> Int4, + register_max_requests -> Int4, + register_interval_seconds -> Int4, + image_max_requests -> Int4, + image_interval_seconds -> Int4, + comment_max_requests -> Int4, + comment_interval_seconds -> Int4, + search_max_requests -> Int4, + search_interval_seconds -> Int4, published_at -> Timestamptz, updated_at -> Nullable, - import_user_settings -> Int4, - import_user_settings_per_second -> Int4, + import_user_settings_max_requests -> Int4, + import_user_settings_interval_seconds -> Int4, } } @@ -1258,6 +1258,7 @@ diesel::joinable!(report_combined -> post_report (post_report_id)); diesel::joinable!(report_combined -> private_message_report (private_message_report_id)); diesel::joinable!(search_combined -> comment (comment_id)); diesel::joinable!(search_combined -> community (community_id)); +diesel::joinable!(search_combined -> multi_community (multi_community_id)); diesel::joinable!(search_combined -> person (person_id)); diesel::joinable!(search_combined -> post (post_id)); diesel::joinable!(site -> instance (instance_id)); diff --git a/crates/db_views/site/src/api.rs b/crates/db_views/site/src/api.rs index 24d59f42a..4f0983f73 100644 --- a/crates/db_views/site/src/api.rs +++ b/crates/db_views/site/src/api.rs @@ -126,18 +126,20 @@ pub struct CreateSite { pub discussion_languages: Option>, pub slur_filter_regex: Option, pub actor_name_max_length: Option, - pub rate_limit_message: Option, - pub rate_limit_message_per_second: Option, - pub rate_limit_post: Option, - pub rate_limit_post_per_second: Option, - pub rate_limit_register: Option, - pub rate_limit_register_per_second: Option, - pub rate_limit_image: Option, - pub rate_limit_image_per_second: Option, - pub rate_limit_comment: Option, - pub rate_limit_comment_per_second: Option, - pub rate_limit_search: Option, - pub rate_limit_search_per_second: Option, + pub rate_limit_message_max_requests: Option, + pub rate_limit_message_interval_seconds: Option, + pub rate_limit_post_max_requests: Option, + pub rate_limit_post_interval_seconds: Option, + pub rate_limit_register_max_requests: Option, + pub rate_limit_register_interval_seconds: Option, + pub rate_limit_image_max_requests: Option, + pub rate_limit_image_interval_seconds: Option, + pub rate_limit_comment_max_requests: Option, + pub rate_limit_comment_interval_seconds: Option, + pub rate_limit_search_max_requests: Option, + pub rate_limit_search_interval_seconds: Option, + pub rate_limit_import_user_settings_max_requests: Option, + pub rate_limit_import_user_settings_interval_seconds: Option, pub federation_enabled: Option, pub captcha_enabled: Option, pub captcha_difficulty: Option, @@ -223,23 +225,26 @@ pub struct EditSite { /// The max length of actor names. pub actor_name_max_length: Option, /// The number of messages allowed in a given time frame. - pub rate_limit_message: Option, - pub rate_limit_message_per_second: Option, + pub rate_limit_message_max_requests: Option, + pub rate_limit_message_interval_seconds: Option, /// The number of posts allowed in a given time frame. - pub rate_limit_post: Option, - pub rate_limit_post_per_second: Option, + pub rate_limit_post_max_requests: Option, + pub rate_limit_post_interval_seconds: Option, /// The number of registrations allowed in a given time frame. - pub rate_limit_register: Option, - pub rate_limit_register_per_second: Option, + pub rate_limit_register_max_requests: Option, + pub rate_limit_register_interval_seconds: Option, /// The number of image uploads allowed in a given time frame. - pub rate_limit_image: Option, - pub rate_limit_image_per_second: Option, + pub rate_limit_image_max_requests: Option, + pub rate_limit_image_interval_seconds: Option, /// The number of comments allowed in a given time frame. - pub rate_limit_comment: Option, - pub rate_limit_comment_per_second: Option, + pub rate_limit_comment_max_requests: Option, + pub rate_limit_comment_interval_seconds: Option, /// The number of searches allowed in a given time frame. - pub rate_limit_search: Option, - pub rate_limit_search_per_second: Option, + pub rate_limit_search_max_requests: Option, + pub rate_limit_search_interval_seconds: Option, + /// The number of settings imports or exports allowed in a given time frame. + pub rate_limit_import_user_settings_max_requests: Option, + pub rate_limit_import_user_settings_interval_seconds: Option, /// Whether to enable federation. pub federation_enabled: Option, /// Whether to enable captchas for signups. diff --git a/crates/utils/src/rate_limit.rs b/crates/utils/src/rate_limit.rs index a03a9cd7c..bcc375f41 100644 --- a/crates/utils/src/rate_limit.rs +++ b/crates/utils/src/rate_limit.rs @@ -31,8 +31,8 @@ pub enum ActionType { #[derive(PartialEq, Debug, Copy, Clone)] pub struct BucketConfig { - pub capacity: u32, - pub secs_to_refill: u32, + pub max_requests: u32, + pub interval: u32, } #[derive(Clone)] @@ -52,32 +52,32 @@ impl RateLimit { pub fn with_test_config() -> Self { Self::new(enum_map! { ActionType::Message => BucketConfig { - capacity: 180, - secs_to_refill: 60, + max_requests: 180, + interval: 60, }, ActionType::Post => BucketConfig { - capacity: 6, - secs_to_refill: 300, + max_requests: 6, + interval: 300, }, ActionType::Register => BucketConfig { - capacity: 3, - secs_to_refill: 3600, + max_requests: 3, + interval: 3600, }, ActionType::Image => BucketConfig { - capacity: 6, - secs_to_refill: 3600, + max_requests: 6, + interval: 3600, }, ActionType::Comment => BucketConfig { - capacity: 6, - secs_to_refill: 600, + max_requests: 6, + interval: 600, }, ActionType::Search => BucketConfig { - capacity: 60, - secs_to_refill: 600, + max_requests: 60, + interval: 600, }, ActionType::ImportUserSettings => BucketConfig { - capacity: 1, - secs_to_refill: 24 * 60 * 60, + max_requests: 1, + interval: 24 * 60 * 60, }, }) } @@ -182,8 +182,8 @@ fn new_input( #[allow(clippy::expect_used)] let config = configs.read().expect("read rwlock")[action_type]; - let interval = Duration::from_secs(config.secs_to_refill.into()); - let max_requests = config.capacity.into(); + let interval = Duration::from_secs(config.interval.into()); + let max_requests = config.max_requests.into(); Ok(SimpleInput { interval, max_requests, diff --git a/migrations/2025-06-24-093800_rename-rate-limit-columns/down.sql b/migrations/2025-06-24-093800_rename-rate-limit-columns/down.sql new file mode 100644 index 000000000..8e4e04aaa --- /dev/null +++ b/migrations/2025-06-24-093800_rename-rate-limit-columns/down.sql @@ -0,0 +1,28 @@ +ALTER TABLE local_site_rate_limit RENAME COLUMN message_max_requests TO message; + +ALTER TABLE local_site_rate_limit RENAME COLUMN message_interval_seconds TO message_per_second; + +ALTER TABLE local_site_rate_limit RENAME COLUMN post_max_requests TO post; + +ALTER TABLE local_site_rate_limit RENAME COLUMN post_interval_seconds TO post_per_second; + +ALTER TABLE local_site_rate_limit RENAME COLUMN comment_max_requests TO comment; + +ALTER TABLE local_site_rate_limit RENAME COLUMN comment_interval_seconds TO comment_per_second; + +ALTER TABLE local_site_rate_limit RENAME COLUMN register_max_requests TO register; + +ALTER TABLE local_site_rate_limit RENAME COLUMN register_interval_seconds TO register_per_second; + +ALTER TABLE local_site_rate_limit RENAME COLUMN image_max_requests TO image; + +ALTER TABLE local_site_rate_limit RENAME COLUMN image_interval_seconds TO image_per_second; + +ALTER TABLE local_site_rate_limit RENAME COLUMN search_max_requests TO search; + +ALTER TABLE local_site_rate_limit RENAME COLUMN search_interval_seconds TO search_per_second; + +ALTER TABLE local_site_rate_limit RENAME COLUMN import_user_settings_max_requests TO import_user_settings; + +ALTER TABLE local_site_rate_limit RENAME COLUMN import_user_settings_interval_seconds TO import_user_settings_per_second; + diff --git a/migrations/2025-06-24-093800_rename-rate-limit-columns/up.sql b/migrations/2025-06-24-093800_rename-rate-limit-columns/up.sql new file mode 100644 index 000000000..9486a93db --- /dev/null +++ b/migrations/2025-06-24-093800_rename-rate-limit-columns/up.sql @@ -0,0 +1,28 @@ +ALTER TABLE local_site_rate_limit RENAME COLUMN message TO message_max_requests; + +ALTER TABLE local_site_rate_limit RENAME COLUMN message_per_second TO message_interval_seconds; + +ALTER TABLE local_site_rate_limit RENAME COLUMN post TO post_max_requests; + +ALTER TABLE local_site_rate_limit RENAME COLUMN post_per_second TO post_interval_seconds; + +ALTER TABLE local_site_rate_limit RENAME COLUMN comment TO comment_max_requests; + +ALTER TABLE local_site_rate_limit RENAME COLUMN comment_per_second TO comment_interval_seconds; + +ALTER TABLE local_site_rate_limit RENAME COLUMN register TO register_max_requests; + +ALTER TABLE local_site_rate_limit RENAME COLUMN register_per_second TO register_interval_seconds; + +ALTER TABLE local_site_rate_limit RENAME COLUMN image TO image_max_requests; + +ALTER TABLE local_site_rate_limit RENAME COLUMN image_per_second TO image_interval_seconds; + +ALTER TABLE local_site_rate_limit RENAME COLUMN search TO search_max_requests; + +ALTER TABLE local_site_rate_limit RENAME COLUMN search_per_second TO search_interval_seconds; + +ALTER TABLE local_site_rate_limit RENAME COLUMN import_user_settings TO import_user_settings_max_requests; + +ALTER TABLE local_site_rate_limit RENAME COLUMN import_user_settings_per_second TO import_user_settings_interval_seconds; +