From bb0c2d95380f45a40f76a6980225320b607e9498 Mon Sep 17 00:00:00 2001 From: Bogdanov Anton Date: Mon, 9 Dec 2024 11:13:35 +0300 Subject: [PATCH 1/2] migrate primary and foreign keys from ID to UUID --- CHANGELOG.md | 4 + app/commands/add_excludes_group_command.rb | 2 +- app/controllers/api/v1/insights_controller.rb | 4 +- app/controllers/concerns/invitationable.rb | 12 +- .../frontend/access_tokens_controller.rb | 4 +- .../frontend/api_access_tokens_controller.rb | 2 +- .../companies/configurations_controller.rb | 2 +- .../companies/transfers_controller.rb | 4 +- .../frontend/companies/users_controller.rb | 2 +- .../frontend/companies_controller.rb | 10 +- .../frontend/entities/ignores_controller.rb | 4 +- .../frontend/excludes/groups_controller.rb | 8 +- .../frontend/insights_controller.rb | 4 +- .../frontend/invites_controller.rb | 4 +- .../frontend/notifications_controller.rb | 6 +- .../repository_insights_controller.rb | 2 +- .../frontend/repositories_controller.rb | 2 +- .../frontend/webhooks_controller.rb | 4 +- .../frontend/work_times_controller.rb | 2 +- .../companies/configurations_controller.rb | 17 +- .../web/companies/repositories_controller.rb | 4 +- app/controllers/web/companies_controller.rb | 6 +- app/controllers/web/profiles_controller.rb | 10 +- .../web/repositories_controller.rb | 4 +- .../webhooks/cryptoclouds_controller.rb | 4 +- .../AccessToken/AccessTokenNewModal.jsx | 2 +- .../requests/createAccessTokenRequest.jsx | 2 +- .../components/compounds/Company/Company.jsx | 6 +- .../compounds/Company/CompanyNewModal.jsx | 2 +- .../Company/requests/fetchInsightsRequest.jsx | 4 +- .../CompanyEdit/CompanyEditInsights.jsx | 10 +- .../CompanyEdit/CompanyEditNotifications.jsx | 38 +- .../CompanyEdit/CompanyEditPrivacy.jsx | 20 +- .../CompanyEdit/CompanyEditPullRequests.jsx | 20 +- .../CompanyEdit/CompanyEditSettings.jsx | 2 +- .../CompanyEdit/CompanyEditTransfer.jsx | 12 +- .../requests/removeExcludeGroupRequest.jsx | 4 +- .../requests/removeIgnoreRequest.jsx | 4 +- .../requests/removeNotificationRequest.jsx | 4 +- .../requests/removeWebhookRequest.jsx | 4 +- .../requests/transferCompanyRequest.jsx | 4 +- .../updateCompanyConfigurationRequest.jsx | 4 +- .../compounds/Profile/ProfilePrivacy.jsx | 20 +- .../requests/removeAcceptedInviteRequest.jsx | 4 +- .../Profile/requests/removeInviteRequest.jsx | 4 +- .../compounds/Repository/Repository.jsx | 8 +- .../compounds/Repository/RepositoryForm.jsx | 6 +- .../Repository/RepositoryNewModal.jsx | 2 +- .../requests/fetchInsightsRequest.jsx | 4 +- .../fetchRepositoryInsightsRequest.jsx | 4 +- .../components/compounds/Wizard/Wizard.jsx | 10 +- app/models/application_record.rb | 2 + .../api_access_token_serializer.rb | 2 +- app/serializers/company_serializer.rb | 4 +- app/serializers/entity/ignore_serializer.rb | 2 +- app/serializers/excludes/group_serializer.rb | 4 +- app/serializers/insight_serializer.rb | 2 - app/serializers/invite_serializer.rb | 2 +- app/serializers/notification_serializer.rb | 6 +- app/serializers/repository_serializer.rb | 2 +- app/serializers/webhook_serializer.rb | 2 +- .../admin/companies/index.html.erb | 2 - .../admin/repositories/index.html.erb | 2 - .../controllers/admin/users/index.html.erb | 2 - .../companies/configurations/edit.html.erb | 12 +- .../controllers/web/companies/index.html.erb | 12 +- .../controllers/web/profiles/show.html.erb | 2 +- .../web/repositories/index.html.erb | 6 +- config/application.rb | 2 + .../20241207181125_change_primary_keys.rb | 308 ++++ db/migrate/20241207182227_backfill_data.rb | 209 +++ db/structure.sql | 1420 ++++++----------- .../authkeeper/fetch_session_service.rb | 2 +- .../authkeeper/generate_token_service.rb | 2 +- .../authkeeper/fetch_session_service_spec.rb | 6 +- .../api/v1/companies_controller_spec.rb | 4 +- .../api/v1/insights_controller_spec.rb | 8 +- .../frontend/access_tokens_controller_spec.rb | 8 +- .../api_access_tokens_controller_spec.rb | 4 +- .../configurations_controller_spec.rb | 6 +- .../companies/transfers_controller_spec.rb | 10 +- .../companies/users_controller_spec.rb | 2 +- .../frontend/companies_controller_spec.rb | 2 +- .../entities/ignores_controller_spec.rb | 8 +- .../excludes/groups_controller_spec.rb | 6 +- .../frontend/insights_controller_spec.rb | 10 +- .../frontend/invites_controller_spec.rb | 10 +- .../frontend/notifications_controller_spec.rb | 14 +- .../repository_insights_controller_spec.rb | 2 +- .../frontend/repositories_controller_spec.rb | 14 +- .../frontend/webhooks_controller_spec.rb | 16 +- .../frontend/work_times_controller_spec.rb | 2 +- .../configurations_controller_spec.rb | 6 +- .../companies/repositories_controller_spec.rb | 6 +- .../web/companies_controller_spec.rb | 4 +- .../web/repositories_controller_spec.rb | 4 +- .../omniauth_callbacks_controller_spec.rb | 4 +- .../web/welcome_controller_spec.rb | 2 +- .../webhooks/cryptoclouds_controller_spec.rb | 4 +- spec/requests/api/v1/companies_spec.rb | 6 +- spec/requests/api/v1/repositories_spec.rb | 4 +- .../services/insights/time/for_review_spec.rb | 36 +- swagger/v1/swagger.yaml | 9 +- 103 files changed, 1317 insertions(+), 1240 deletions(-) create mode 100644 db/migrate/20241207181125_change_primary_keys.rb create mode 100644 db/migrate/20241207182227_backfill_data.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 05bed180..1d3169bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## Unreleased +### Modified +- migrate primary and foreign keys from ID to UUID + ## [2.0.2] - 2024-12-06 ### Added - open graph tags diff --git a/app/commands/add_excludes_group_command.rb b/app/commands/add_excludes_group_command.rb index d38ca7bf..4243313c 100644 --- a/app/commands/add_excludes_group_command.rb +++ b/app/commands/add_excludes_group_command.rb @@ -50,7 +50,7 @@ def filter_rules(excludes_rules) errors = validate(excludes_rule.to_h) next if errors.any? - excludes_rule.merge(uuid: SecureRandom.uuid) + excludes_rule end end diff --git a/app/controllers/api/v1/insights_controller.rb b/app/controllers/api/v1/insights_controller.rb index fd605f1c..28aad746 100644 --- a/app/controllers/api/v1/insights_controller.rb +++ b/app/controllers/api/v1/insights_controller.rb @@ -36,11 +36,11 @@ def find_insightable end def find_company - @insightable = authorized_scope(Company.order(id: :desc)).find_by(uuid: params[:company_id]) + @insightable = authorized_scope(Company.order(id: :desc)).find_by(id: params[:company_id]) end def find_repository - @insightable = authorized_scope(Repository.order(id: :desc)).find_by(uuid: params[:repository_id]) + @insightable = authorized_scope(Repository.order(id: :desc)).find_by(id: params[:repository_id]) end def visible_insights diff --git a/app/controllers/concerns/invitationable.rb b/app/controllers/concerns/invitationable.rb index 09e21056..2052b714 100644 --- a/app/controllers/concerns/invitationable.rb +++ b/app/controllers/concerns/invitationable.rb @@ -11,15 +11,15 @@ def find_invite invite = Invite.find_by(code: params[:invite_code], email: params[:invite_email]) return if invite.blank? - current_user ? accept_invite(current_user, invite.uuid) : save_invite_cookies(invite) + current_user ? accept_invite(current_user, invite.id) : save_invite_cookies(invite) end # rubocop: disable Metrics/AbcSize, Metrics/CyclomaticComplexity - def accept_invite(user, invite_uuid=nil) - invite_uuid ||= cookies[:pullmetry_invite_uuid] - return unless invite_uuid + def accept_invite(user, invite_id=nil) + invite_id ||= cookies[:pullmetry_invite_uuid] + return unless invite_id - invite = Invite.find_by(uuid: invite_uuid) + invite = Invite.find_by(id: invite_id) return clear_invite_cookies if invite.nil? # skip self invites return clear_invite_cookies if invite.coowner? && invite.inviteable_id == user.id @@ -36,7 +36,7 @@ def clear_invite_cookies def save_invite_cookies(invite) cookies[:pullmetry_invite_uuid] = { - value: invite.uuid, + value: invite.id, expires: 1.week.from_now } end diff --git a/app/controllers/frontend/access_tokens_controller.rb b/app/controllers/frontend/access_tokens_controller.rb index 8a777083..b5855f65 100644 --- a/app/controllers/frontend/access_tokens_controller.rb +++ b/app/controllers/frontend/access_tokens_controller.rb @@ -21,14 +21,14 @@ def create def find_company return unless params[:company_id] - @tokenable = Company.find_by!(uuid: params[:company_id]) + @tokenable = Company.find(params[:company_id]) end def find_repository return if @tokenable return unless params[:repository_id] - @tokenable = current_user.repositories.find_by!(uuid: params[:repository_id]) + @tokenable = current_user.repositories.find(params[:repository_id]) end def access_token_params diff --git a/app/controllers/frontend/api_access_tokens_controller.rb b/app/controllers/frontend/api_access_tokens_controller.rb index d2c7b0dc..b46648f2 100644 --- a/app/controllers/frontend/api_access_tokens_controller.rb +++ b/app/controllers/frontend/api_access_tokens_controller.rb @@ -28,7 +28,7 @@ def json_response(response, result) end def find_api_access_token - @api_access_token = current_user.api_access_tokens.find_by!(uuid: params[:id]) + @api_access_token = current_user.api_access_tokens.find(params[:id]) end end end diff --git a/app/controllers/frontend/companies/configurations_controller.rb b/app/controllers/frontend/companies/configurations_controller.rb index fe038986..f5c5681c 100644 --- a/app/controllers/frontend/companies/configurations_controller.rb +++ b/app/controllers/frontend/companies/configurations_controller.rb @@ -19,7 +19,7 @@ def update private def find_company - @company = Company.find_by!(uuid: params[:company_id]) + @company = Company.find(params[:company_id]) end def configuration_params diff --git a/app/controllers/frontend/companies/transfers_controller.rb b/app/controllers/frontend/companies/transfers_controller.rb index cab47735..018a79e1 100644 --- a/app/controllers/frontend/companies/transfers_controller.rb +++ b/app/controllers/frontend/companies/transfers_controller.rb @@ -19,11 +19,11 @@ def create private def find_company - @company = current_user.companies.find_by!(uuid: params[:company_id]) + @company = current_user.companies.find(params[:company_id]) end def find_target_user - @user = ::User.where.not(id: current_user.id).find_by!(uuid: params[:user_uuid]) + @user = ::User.where.not(id: current_user.id).find(params[:user_id]) end end end diff --git a/app/controllers/frontend/companies/users_controller.rb b/app/controllers/frontend/companies/users_controller.rb index aa0a0352..547c3084 100644 --- a/app/controllers/frontend/companies/users_controller.rb +++ b/app/controllers/frontend/companies/users_controller.rb @@ -15,7 +15,7 @@ def destroy private def find_companies_user - @companies_user = ::Companies::User.find_by!(uuid: params[:id]) + @companies_user = ::Companies::User.find(params[:id]) end end end diff --git a/app/controllers/frontend/companies_controller.rb b/app/controllers/frontend/companies_controller.rb index 71e51175..0d39f943 100644 --- a/app/controllers/frontend/companies_controller.rb +++ b/app/controllers/frontend/companies_controller.rb @@ -17,20 +17,20 @@ def create def json_response(response, result) { - result: response.serializer(result, CompanySerializer, only: %i[uuid]) + result: response.serializer(result, CompanySerializer, only: %i[id]) } end def user - return current_user if current_user.uuid == account_uuid || account_uuid.nil? + return current_user if current_user.id == account_id || account_id.nil? - account = User.find_by!(uuid: account_uuid) + account = User.find(account_id) current_user.receive_invites.coowner.accepted.write.find_by!(inviteable_id: account.id) account end - def account_uuid - params[:company][:user_uuid] + def account_id + params[:company][:user_id] end def company_params diff --git a/app/controllers/frontend/entities/ignores_controller.rb b/app/controllers/frontend/entities/ignores_controller.rb index 08f12e9a..ecd0ee5f 100644 --- a/app/controllers/frontend/entities/ignores_controller.rb +++ b/app/controllers/frontend/entities/ignores_controller.rb @@ -31,11 +31,11 @@ def json_response(response, result) end def find_company - @company = current_user.available_write_companies.find_by!(uuid: params[:company_id]) + @company = current_user.available_write_companies.find(params[:company_id]) end def find_entity_ignore - @entity_ignore = Entity::Ignore.find_by!(uuid: params[:id]) + @entity_ignore = Entity::Ignore.find(params[:id]) end def entity_ignore_params diff --git a/app/controllers/frontend/excludes/groups_controller.rb b/app/controllers/frontend/excludes/groups_controller.rb index 0fc87b90..36b2a16b 100644 --- a/app/controllers/frontend/excludes/groups_controller.rb +++ b/app/controllers/frontend/excludes/groups_controller.rb @@ -38,19 +38,19 @@ def json_response(response, result) end def find_company - @company = current_user.available_write_companies.find_by!(uuid: params[:company_id]) + @company = current_user.available_write_companies.find(params[:company_id]) end def find_excludes_group - @excludes_group = ::Excludes::Group.find_by!(uuid: params[:id]) + @excludes_group = ::Excludes::Group.find(params[:id]) end def excludes_rules(excludes_group_id) ::Excludes::Rule .where(excludes_group_id: excludes_group_id) .joins(:excludes_group) - .hashable_pluck(:uuid, :target, :condition, :value, 'excludes_groups.uuid') - .group_by { |rule| rule[:excludes_groups_uuid] } + .hashable_pluck(:id, :target, :condition, :value, :excludes_group_id) + .group_by { |rule| rule[:excludes_group_id] } end def create_excludes_rules_params diff --git a/app/controllers/frontend/insights_controller.rb b/app/controllers/frontend/insights_controller.rb index 4ad21686..696656fb 100644 --- a/app/controllers/frontend/insights_controller.rb +++ b/app/controllers/frontend/insights_controller.rb @@ -54,11 +54,11 @@ def find_insightable end def find_company - @insightable = authorized_scope(Company.order(id: :desc)).find_by(uuid: params[:company_id]) + @insightable = authorized_scope(Company.order(id: :desc)).find_by(id: params[:company_id]) end def find_repository - @insightable = authorized_scope(Repository.order(id: :desc)).find_by(uuid: params[:repository_id]) + @insightable = authorized_scope(Repository.order(id: :desc)).find_by(id: params[:repository_id]) end def visible_insights diff --git a/app/controllers/frontend/invites_controller.rb b/app/controllers/frontend/invites_controller.rb index 527a7bab..12446f64 100644 --- a/app/controllers/frontend/invites_controller.rb +++ b/app/controllers/frontend/invites_controller.rb @@ -37,11 +37,11 @@ def find_inviteable end def find_invite - @invite = Invite.find_by!(uuid: params[:id]) + @invite = Invite.find(params[:id]) end def find_company - current_user.available_write_companies.find_by(uuid: params[:company_id]) + current_user.available_write_companies.find_by(id: params[:company_id]) end def find_user diff --git a/app/controllers/frontend/notifications_controller.rb b/app/controllers/frontend/notifications_controller.rb index a1248cca..fe23474a 100644 --- a/app/controllers/frontend/notifications_controller.rb +++ b/app/controllers/frontend/notifications_controller.rb @@ -32,15 +32,15 @@ def json_response(response, result) end def find_company - @company = current_user.available_write_companies.find_by!(uuid: params[:company_id]) + @company = current_user.available_write_companies.find(params[:company_id]) end def find_webhook - @webhook = @company.webhooks.find_by!(uuid: params[:webhook_id]) + @webhook = @company.webhooks.find(params[:webhook_id]) end def find_notification - @notification = Notification.find_by!(uuid: params[:id]) + @notification = Notification.find(params[:id]) end def notification_params diff --git a/app/controllers/frontend/repositories/repository_insights_controller.rb b/app/controllers/frontend/repositories/repository_insights_controller.rb index cf562f58..1b24322d 100644 --- a/app/controllers/frontend/repositories/repository_insights_controller.rb +++ b/app/controllers/frontend/repositories/repository_insights_controller.rb @@ -33,7 +33,7 @@ def json_response(response) end def find_repository - @repository = authorized_scope(Repository.order(id: :desc)).find_by!(uuid: params[:repository_id]) + @repository = authorized_scope(Repository.order(id: :desc)).find(params[:repository_id]) end def visible_insights diff --git a/app/controllers/frontend/repositories_controller.rb b/app/controllers/frontend/repositories_controller.rb index d1c9d4d0..f8c883dc 100644 --- a/app/controllers/frontend/repositories_controller.rb +++ b/app/controllers/frontend/repositories_controller.rb @@ -25,7 +25,7 @@ def json_response(response, result) end def find_company - @company = current_user.companies.find_by!(uuid: params[:repository][:company_uuid]) + @company = current_user.companies.find(params[:repository][:company_id]) end def repository_params diff --git a/app/controllers/frontend/webhooks_controller.rb b/app/controllers/frontend/webhooks_controller.rb index dfa99909..32b1e476 100644 --- a/app/controllers/frontend/webhooks_controller.rb +++ b/app/controllers/frontend/webhooks_controller.rb @@ -31,11 +31,11 @@ def json_response(response, result) end def find_company - @company = current_user.available_write_companies.find_by!(uuid: params[:company_id]) + @company = current_user.available_write_companies.find(params[:company_id]) end def find_webhook - @webhook = Webhook.find_by!(uuid: params[:id]) + @webhook = Webhook.find(params[:id]) end def webhook_params diff --git a/app/controllers/frontend/work_times_controller.rb b/app/controllers/frontend/work_times_controller.rb index fd326fd6..9862156a 100644 --- a/app/controllers/frontend/work_times_controller.rb +++ b/app/controllers/frontend/work_times_controller.rb @@ -21,7 +21,7 @@ def worktimeable end def find_company - current_user.available_write_companies.find_by!(uuid: params[:company_id]) + current_user.available_write_companies.find(params[:company_id]) end def work_time_params diff --git a/app/controllers/web/companies/configurations_controller.rb b/app/controllers/web/companies/configurations_controller.rb index 5dbf756d..db5a3961 100644 --- a/app/controllers/web/companies/configurations_controller.rb +++ b/app/controllers/web/companies/configurations_controller.rb @@ -18,26 +18,25 @@ def edit private def find_company - @company = Company.find_by!(uuid: params[:company_id]) + @company = Company.find(params[:company_id]) @current_config = @company.current_config end def find_ignores - @ignores = @company.entity_ignores.hashable_pluck(:uuid, :entity_value) + @ignores = @company.entity_ignores.hashable_pluck(:id, :entity_value) end def find_invites - @accepted_invites = @company.companies_users.joins(:invite).hashable_pluck(:uuid, :access, 'invites.email') - @invites = @company.invites.waiting.hashable_pluck(:uuid, :email, :access) + @accepted_invites = @company.companies_users.joins(:invite).hashable_pluck(:id, :access, 'invites.email') + @invites = @company.invites.waiting.hashable_pluck(:id, :email, :access) end def find_notifications - @notifications = - @company.notifications.joins(:webhook).hashable_pluck(:uuid, :notification_type, 'webhooks.uuid') + @notifications = @company.notifications.hashable_pluck(:id, :notification_type, :webhook_id) end def find_webhooks - @webhooks = @company.webhooks.hashable_pluck(:uuid, :source, :url) + @webhooks = @company.webhooks.hashable_pluck(:id, :source, :url) end def find_excludes_groups @@ -57,8 +56,8 @@ def excludes_rules Excludes::Rule .joins(:excludes_group) .where(excludes_groups: { insightable: @company }) - .hashable_pluck(:uuid, :target, :condition, :value, 'excludes_groups.uuid') - .group_by { |rule| rule[:excludes_groups_uuid] } + .hashable_pluck(:id, :target, :condition, :value, :excludes_group_id) + .group_by { |rule| rule[:excludes_group_id] } end end end diff --git a/app/controllers/web/companies/repositories_controller.rb b/app/controllers/web/companies/repositories_controller.rb index 8b759bca..83f8ad72 100644 --- a/app/controllers/web/companies/repositories_controller.rb +++ b/app/controllers/web/companies/repositories_controller.rb @@ -18,7 +18,7 @@ def index private def find_company - @company = authorized_scope(Company.all).find_by!(uuid: params[:company_id]) + @company = authorized_scope(Company.all).find(params[:company_id]) end def find_repositories @@ -37,7 +37,7 @@ def find_available_companies .or( Company.where(id: current_user.companies_users.write.select(:company_id)) ) - .pluck(:uuid, :title) + .pluck(:id, :title) .to_h end end diff --git a/app/controllers/web/companies_controller.rb b/app/controllers/web/companies_controller.rb index a9717c76..04be3aff 100644 --- a/app/controllers/web/companies_controller.rb +++ b/app/controllers/web/companies_controller.rb @@ -28,17 +28,17 @@ def find_companies def find_accounts_for_companies @accounts_for_companies = { - current_user.uuid => 'Own account' + current_user.id => 'Own account' }.merge( User .where(id: current_user.receive_invites.coowner.accepted.write.select(:inviteable_id)) - .pluck(:uuid, :email) + .pluck(:id, :email) .to_h ) end def find_company - @company = current_user.companies.find_by!(uuid: params[:id]) + @company = current_user.companies.find(params[:id]) end end end diff --git a/app/controllers/web/profiles_controller.rb b/app/controllers/web/profiles_controller.rb index 1843ad5b..abf7830c 100644 --- a/app/controllers/web/profiles_controller.rb +++ b/app/controllers/web/profiles_controller.rb @@ -28,12 +28,12 @@ def destroy private def find_api_access_tokens - @api_access_tokens = current_user.api_access_tokens.hashable_pluck(:uuid, :value) + @api_access_tokens = current_user.api_access_tokens.hashable_pluck(:id, :value) end def find_invites - @accepted_invites = current_user.invites.accepted.hashable_pluck(:uuid, :email, :access) - @invites = current_user.invites.waiting.hashable_pluck(:uuid, :email, :access) + @accepted_invites = current_user.invites.accepted.hashable_pluck(:id, :email, :access) + @invites = current_user.invites.waiting.hashable_pluck(:id, :email, :access) end def find_used_trial_subscription @@ -64,10 +64,10 @@ def generate_order_ids Rails.cache.fetch('profile_cryptocloud_order_ids_v2') do { regular30: jwt_encoder.encode( - payload: { uuid: current_user.uuid, days_period: 30 } + payload: { uuid: current_user.id, days_period: 30 } ), regular365: jwt_encoder.encode( - payload: { uuid: current_user.uuid, days_period: 365 } + payload: { uuid: current_user.id, days_period: 365 } ) } end diff --git a/app/controllers/web/repositories_controller.rb b/app/controllers/web/repositories_controller.rb index 763d1603..8e888c7d 100644 --- a/app/controllers/web/repositories_controller.rb +++ b/app/controllers/web/repositories_controller.rb @@ -31,7 +31,7 @@ def find_repositories end def find_repository - @repository = current_user.repositories.find_by!(uuid: params[:id]) + @repository = current_user.repositories.find(params[:id]) end def find_available_companies @@ -40,7 +40,7 @@ def find_available_companies .or( Company.where(id: current_user.companies_users.write.select(:company_id)) ) - .pluck(:uuid, :title) + .pluck(:id, :title) .to_h end end diff --git a/app/controllers/webhooks/cryptoclouds_controller.rb b/app/controllers/webhooks/cryptoclouds_controller.rb index d8f20469..9c6b811f 100644 --- a/app/controllers/webhooks/cryptoclouds_controller.rb +++ b/app/controllers/webhooks/cryptoclouds_controller.rb @@ -44,7 +44,7 @@ def validate_status end def find_user - @user = User.find_by!(uuid: user_uuid) + @user = User.find(user_id) end def find_invoice_payload @@ -54,7 +54,7 @@ def find_invoice_payload head :ok end - def user_uuid + def user_id order_id_payload['uuid'] end diff --git a/app/javascript/components/compounds/AccessToken/AccessTokenNewModal.jsx b/app/javascript/components/compounds/AccessToken/AccessTokenNewModal.jsx index 8b503240..8202cf9b 100644 --- a/app/javascript/components/compounds/AccessToken/AccessTokenNewModal.jsx +++ b/app/javascript/components/compounds/AccessToken/AccessTokenNewModal.jsx @@ -14,7 +14,7 @@ export const AccessTokenNewModal = (props) => { return; } - const result = await createAccessTokenRequest({ payload: formStore, uuid: props.uuid, tokenable: props.tokenable }); + const result = await createAccessTokenRequest({ payload: formStore, id: props.id, tokenable: props.tokenable }); if (result.errors) renderErrors(result.errors); else window.location.reload(); diff --git a/app/javascript/components/compounds/AccessToken/requests/createAccessTokenRequest.jsx b/app/javascript/components/compounds/AccessToken/requests/createAccessTokenRequest.jsx index 6fdffb91..0643312d 100644 --- a/app/javascript/components/compounds/AccessToken/requests/createAccessTokenRequest.jsx +++ b/app/javascript/components/compounds/AccessToken/requests/createAccessTokenRequest.jsx @@ -2,7 +2,7 @@ import { apiRequest, csrfToken, objectKeysToSnakeCase } from '../../../../helper export const createAccessTokenRequest = async (payload) => { return await apiRequest({ - url: `/frontend/${payload.tokenable}/${payload.uuid}/access_tokens`, + url: `/frontend/${payload.tokenable}/${payload.id}/access_tokens`, options: { method: 'POST', headers: { diff --git a/app/javascript/components/compounds/Company/Company.jsx b/app/javascript/components/compounds/Company/Company.jsx index fa08f2bf..74741af7 100644 --- a/app/javascript/components/compounds/Company/Company.jsx +++ b/app/javascript/components/compounds/Company/Company.jsx @@ -21,7 +21,7 @@ export const Company = (props) => { if (!pageState.isExpanded) return; if (pageState.entities !== undefined) return; - const fetchInsights = async () => await fetchInsightsRequest(props.uuid); + const fetchInsights = async () => await fetchInsightsRequest(props.id); Promise.all([fetchInsights()]).then(([insightsData]) => { setPageState({ @@ -51,7 +51,7 @@ export const Company = (props) => { return (
- + {
Download insights PDF {editLinks()} diff --git a/app/javascript/components/compounds/Company/CompanyNewModal.jsx b/app/javascript/components/compounds/Company/CompanyNewModal.jsx index f8773fe4..c0e6109d 100644 --- a/app/javascript/components/compounds/Company/CompanyNewModal.jsx +++ b/app/javascript/components/compounds/Company/CompanyNewModal.jsx @@ -13,7 +13,7 @@ export const CompanyNewModal = (props) => { return; } - const result = await createCompanyRequest({ ...formStore, userUuid: props.accountUuid }); + const result = await createCompanyRequest({ ...formStore, userId: props.accountId }); if (result.errors) renderErrors(result.errors); else window.location = '/companies'; diff --git a/app/javascript/components/compounds/Company/requests/fetchInsightsRequest.jsx b/app/javascript/components/compounds/Company/requests/fetchInsightsRequest.jsx index 69805617..444d71dc 100644 --- a/app/javascript/components/compounds/Company/requests/fetchInsightsRequest.jsx +++ b/app/javascript/components/compounds/Company/requests/fetchInsightsRequest.jsx @@ -1,7 +1,7 @@ import { apiRequest } from '../../../../helpers'; -export const fetchInsightsRequest = async (companyUuid) => { +export const fetchInsightsRequest = async (companyId) => { return await apiRequest({ - url: `/frontend/companies/${companyUuid}/insights.json` + url: `/frontend/companies/${companyId}/insights.json` }); } diff --git a/app/javascript/components/compounds/CompanyEdit/CompanyEditInsights.jsx b/app/javascript/components/compounds/CompanyEdit/CompanyEditInsights.jsx index b00bcfba..3a30d843 100644 --- a/app/javascript/components/compounds/CompanyEdit/CompanyEditInsights.jsx +++ b/app/javascript/components/compounds/CompanyEdit/CompanyEditInsights.jsx @@ -50,35 +50,35 @@ export const CompanyEditInsights = (props) => { const toggleInsightField = async (insightName) => { const insightFields = pageState.insightFields.includes(insightName) ? pageState.insightFields.slice().filter((item) => item !== insightName) : [].concat(insightName, pageState.insightFields); - const result = await updateCompanyConfigurationRequest(props.companyUuid, { insight_fields: insightFields }); + const result = await updateCompanyConfigurationRequest(props.companyId, { insight_fields: insightFields }); if (result.errors) renderErrors(result.errors); else setPageState({ ...pageState, insightFields: insightFields }); } const updateMainAttribute = async (value) => { - const result = await updateCompanyConfigurationRequest(props.companyUuid, { main_attribute: value }); + const result = await updateCompanyConfigurationRequest(props.companyId, { main_attribute: value }); if (result.errors) renderErrors(result.errors); else setPageState({ ...pageState, mainAttribute: value }); } const updateAverageType = async (value) => { - const result = await updateCompanyConfigurationRequest(props.companyUuid, { average_type: value }); + const result = await updateCompanyConfigurationRequest(props.companyId, { average_type: value }); if (result.errors) renderErrors(result.errors); else setPageState({ ...pageState, averageType: value }); } const toggleInsightRatio = async () => { - const result = await updateCompanyConfigurationRequest(props.companyUuid, { insight_ratio: !pageState.insightRatio }); + const result = await updateCompanyConfigurationRequest(props.companyId, { insight_ratio: !pageState.insightRatio }); if (result.errors) renderErrors(result.errors); else setPageState({ ...pageState, insightRatio: !pageState.insightRatio }); } const updateInsightRatioType = async (value) => { - const result = await updateCompanyConfigurationRequest(props.companyUuid, { insight_ratio_type: value }); + const result = await updateCompanyConfigurationRequest(props.companyId, { insight_ratio_type: value }); if (result.errors) renderErrors(result.errors); else setPageState({ ...pageState, insightRatioType: value }); diff --git a/app/javascript/components/compounds/CompanyEdit/CompanyEditNotifications.jsx b/app/javascript/components/compounds/CompanyEdit/CompanyEditNotifications.jsx index d82640b3..2fdb3174 100644 --- a/app/javascript/components/compounds/CompanyEdit/CompanyEditNotifications.jsx +++ b/app/javascript/components/compounds/CompanyEdit/CompanyEditNotifications.jsx @@ -39,7 +39,7 @@ export const CompanyEditNotifications = (props) => { const [notificationFormStore, setNotificationFormStore] = createStore({ notificationType: 'insights_data', - notificationWebhookUuid: props.webhooks.length > 0 ? props.webhooks[0].uuid : null, + notificationWebhookId: props.webhooks.length > 0 ? props.webhooks[0].id : null, }); /* eslint-enable solid/reactivity */ @@ -54,7 +54,7 @@ export const CompanyEditNotifications = (props) => { const webhooksForSelect = createMemo(() => { return pageState.webhooks.reduce((result, webhook) => { - result[webhook.uuid] = `${webhook.source}: ${webhook.url}` + result[webhook.id] = `${webhook.source}: ${webhook.url}` return result; }, {}); }); @@ -67,30 +67,30 @@ export const CompanyEditNotifications = (props) => { } const saveWebhook = async () => { - const result = await createWebhookRequest({ webhook: webhookFormStore, companyId: props.companyUuid }); + const result = await createWebhookRequest({ webhook: webhookFormStore, companyId: props.companyId }); if (result.errors) renderErrors(result.errors); else { batch(() => { const webhooks = pageState.webhooks.concat(result.result); - const notificationWebhookUuid = webhooks.length === 1 ? webhooks[0].uuid : notificationFormStore.notificationWebhookUuid; + const notificationWebhookId = webhooks.length === 1 ? webhooks[0].id : notificationFormStore.notificationWebhookId; setPageState({ ...pageState, webhooks: webhooks, webhookModalIsOpen: false }); setWebhookFormStore({ source: 'slack', url: '' }); - setNotificationFormStore({ ...notificationFormStore, notificationWebhookUuid: notificationWebhookUuid }); + setNotificationFormStore({ ...notificationFormStore, notificationWebhookId: notificationWebhookId }); closeModal(); }); } } - const removeWebhook = async (uuid) => { - const result = await removeWebhookRequest(uuid); + const removeWebhook = async (id) => { + const result = await removeWebhookRequest(id); if (result.errors) renderErrors(result.errors); else setPageState({ ...pageState, - webhooks: pageState.webhooks.filter((item) => item.uuid !== uuid), - notifications: pageState.notifications.filter((item) => item.webhooksUuid !== uuid) + webhooks: pageState.webhooks.filter((item) => item.id !== id), + notifications: pageState.notifications.filter((item) => item.webhook_id !== id) }); } @@ -104,8 +104,8 @@ export const CompanyEditNotifications = (props) => { const saveNotification = async () => { const result = await createNotificationRequest({ notification: { notificationType: notificationFormStore.notificationType }, - webhookId: notificationFormStore.notificationWebhookUuid, - companyId: props.companyUuid + webhookId: notificationFormStore.notificationWebhookId, + companyId: props.companyId }); if (result.errors) renderErrors(result.errors); @@ -118,11 +118,11 @@ export const CompanyEditNotifications = (props) => { } } - const removeNotification = async (uuid) => { - const result = await removeNotificationRequest(uuid); + const removeNotification = async (id) => { + const result = await removeNotificationRequest(id); if (result.errors) renderErrors(result.errors); - else setPageState({ ...pageState, notifications: pageState.notifications.filter((item) => item.uuid !== uuid) }); + else setPageState({ ...pageState, notifications: pageState.notifications.filter((item) => item.id !== id) }); } return ( @@ -149,7 +149,7 @@ export const CompanyEditNotifications = (props) => {

removeWebhook(webhook.uuid)} + onClick={() => removeWebhook(webhook.id)} >X

@@ -184,7 +184,7 @@ export const CompanyEditNotifications = (props) => { {(notification) => { - const webhook = pageState.webhooks.find((item) => item.uuid === notification.webhooksUuid); + const webhook = pageState.webhooks.find((item) => item.id === notification.webhook_id); return ( @@ -194,7 +194,7 @@ export const CompanyEditNotifications = (props) => {

removeNotification(notification.uuid)} + onClick={() => removeNotification(notification.id)} >X

@@ -260,8 +260,8 @@ export const CompanyEditNotifications = (props) => { classList="w-full" labelText="Webhook" items={webhooksForSelect()} - selectedValue={notificationFormStore.notificationWebhookUuid} - onSelect={(value) => setNotificationFormStore('notificationWebhookUuid', value)} + selectedValue={notificationFormStore.notificationWebhookId} + onSelect={(value) => setNotificationFormStore('notificationWebhookId', value)} />
diff --git a/app/javascript/components/compounds/CompanyEdit/CompanyEditPrivacy.jsx b/app/javascript/components/compounds/CompanyEdit/CompanyEditPrivacy.jsx index a8223846..de3cdff5 100644 --- a/app/javascript/components/compounds/CompanyEdit/CompanyEditPrivacy.jsx +++ b/app/javascript/components/compounds/CompanyEdit/CompanyEditPrivacy.jsx @@ -32,14 +32,14 @@ export const CompanyEditPrivacy = (props) => { const { Flash, renderErrors } = createFlash(); const togglePrivate = async () => { - const result = await updateCompanyConfigurationRequest(props.companyUuid, { private: !pageState.private }); + const result = await updateCompanyConfigurationRequest(props.companyId, { private: !pageState.private }); if (result.errors) renderErrors(result.errors); else setPageState({ ...pageState, private: !pageState.private }); } const onInviteCreate = async () => { - const result = await createInviteRequest({ invite: formStore, companyId: props.companyUuid }); + const result = await createInviteRequest({ invite: formStore, companyId: props.companyId }); if (result.errors) renderErrors(result.errors); else { @@ -51,18 +51,18 @@ export const CompanyEditPrivacy = (props) => { } } - const onInviteRemove = async (uuid) => { - const result = await removeInviteRequest(uuid); + const onInviteRemove = async (id) => { + const result = await removeInviteRequest(id); if (result.errors) renderErrors(result.errors); - else setPageState({ ...pageState, invites: pageState.invites.filter((item) => item.uuid !== uuid) }); + else setPageState({ ...pageState, invites: pageState.invites.filter((item) => item.id !== id) }); } - const onAcceptedInviteRemove = async (uuid) => { - const result = await removeAcceptedInviteRequest(uuid); + const onAcceptedInviteRemove = async (id) => { + const result = await removeAcceptedInviteRequest(id); if (result.errors) renderErrors(result.errors); - else setPageState({ ...pageState, acceptedInvites: pageState.acceptedInvites.filter((item) => item.uuid !== uuid) }); + else setPageState({ ...pageState, acceptedInvites: pageState.acceptedInvites.filter((item) => item.id !== id) }); } return ( @@ -92,7 +92,7 @@ export const CompanyEditPrivacy = (props) => {

onAcceptedInviteRemove(invite.uuid)} + onClick={() => onAcceptedInviteRemove(invite.id)} >X

@@ -118,7 +118,7 @@ export const CompanyEditPrivacy = (props) => {

onInviteRemove(invite.uuid)} + onClick={() => onInviteRemove(invite.id)} >X

diff --git a/app/javascript/components/compounds/CompanyEdit/CompanyEditPullRequests.jsx b/app/javascript/components/compounds/CompanyEdit/CompanyEditPullRequests.jsx index 588d8c9c..6f84f373 100644 --- a/app/javascript/components/compounds/CompanyEdit/CompanyEditPullRequests.jsx +++ b/app/javascript/components/compounds/CompanyEdit/CompanyEditPullRequests.jsx @@ -41,7 +41,7 @@ export const CompanyEditPullRequests = (props) => { const { Flash, renderErrors } = createFlash(); const updateFetchPeriod = async () => { - const result = await updateCompanyConfigurationRequest(props.companyUuid, { fetch_period: parseInt(pageState.fetchPeriod) }); + const result = await updateCompanyConfigurationRequest(props.companyId, { fetch_period: parseInt(pageState.fetchPeriod) }); if (result.errors) renderErrors(result.errors); else setPageState({ ...pageState, defaultFetchPeriod: pageState.fetchPeriod }); @@ -50,7 +50,7 @@ export const CompanyEditPullRequests = (props) => { const resetFetchPeriod = () => setPageState({ ...pageState, fetchPeriod: pageState.defaultFetchPeriod }); const onIgnoreCreate = async () => { - const result = await createIgnoreRequest({ entityIgnore: ignoreFormStore, companyId: props.companyUuid }); + const result = await createIgnoreRequest({ entityIgnore: ignoreFormStore, companyId: props.companyId }); if (result.errors) renderErrors(result.errors); else { @@ -62,18 +62,18 @@ export const CompanyEditPullRequests = (props) => { } } - const onIgnoreRemove = async (uuid) => { - const result = await removeIgnoreRequest(uuid); + const onIgnoreRemove = async (id) => { + const result = await removeIgnoreRequest(id); if (result.errors) renderErrors(result.errors); - else setPageState({ ...pageState, ignores: pageState.ignores.filter((item) => item.uuid !== uuid) }); + else setPageState({ ...pageState, ignores: pageState.ignores.filter((item) => item.id !== id) }); } - const onExcludeGroupRemove = async (uuid) => { - const result = await removeExcludeGroupRequest(uuid); + const onExcludeGroupRemove = async (id) => { + const result = await removeExcludeGroupRequest(id); if (result.errors) renderErrors(result.errors); - else setPageState({ ...pageState, excludesGroups: pageState.excludesGroups.filter((item) => item.uuid !== uuid) }); + else setPageState({ ...pageState, excludesGroups: pageState.excludesGroups.filter((item) => item.id !== id) }); } return ( @@ -119,7 +119,7 @@ export const CompanyEditPullRequests = (props) => {

onExcludeGroupRemove(excludeGroup.uuid)} + onClick={() => onExcludeGroupRemove(excludeGroup.id)} >X

@@ -151,7 +151,7 @@ export const CompanyEditPullRequests = (props) => {

onIgnoreRemove(ignore.uuid)} + onClick={() => onIgnoreRemove(ignore.id)} >X

diff --git a/app/javascript/components/compounds/CompanyEdit/CompanyEditSettings.jsx b/app/javascript/components/compounds/CompanyEdit/CompanyEditSettings.jsx index 07857bb5..f1bb9f74 100644 --- a/app/javascript/components/compounds/CompanyEdit/CompanyEditSettings.jsx +++ b/app/javascript/components/compounds/CompanyEdit/CompanyEditSettings.jsx @@ -26,7 +26,7 @@ export const CompanyEditSettings = (props) => { const { Flash, renderErrors, renderNotices } = createFlash(); const UpdateSettings = async () => { - const result = await updateWorkTimeRequest({ ...formStore, companyId: props.companyUuid }); + const result = await updateWorkTimeRequest({ ...formStore, companyId: props.companyId }); if (result.errors) renderErrors(result.errors); else renderNotices(['Work time is saved']); diff --git a/app/javascript/components/compounds/CompanyEdit/CompanyEditTransfer.jsx b/app/javascript/components/compounds/CompanyEdit/CompanyEditTransfer.jsx index f2eb3afd..d346572e 100644 --- a/app/javascript/components/compounds/CompanyEdit/CompanyEditTransfer.jsx +++ b/app/javascript/components/compounds/CompanyEdit/CompanyEditTransfer.jsx @@ -6,13 +6,13 @@ import { transferCompanyRequest } from './requests/transferCompanyRequest'; export const CompanyEditTransfer = (props) => { const [formStore, setFormStore] = createStore({ - userUuid: '' + userId: '' }); const { Flash, renderErrors } = createFlash(); const onSubmit = async () => { - const result = await transferCompanyRequest(props.companyUuid, formStore); + const result = await transferCompanyRequest(props.companyId, formStore); if (result.errors) renderErrors(result.errors); else window.location = result.redirect_path; @@ -22,15 +22,15 @@ export const CompanyEditTransfer = (props) => { <>

Transfer

-

You can transfer company's ownership to another user. If such user is allowed to create new companies then ownership will be transfered. You just need to specify another user's uuid. This action is not revertable.

+

You can transfer company's ownership to another user. If such user is allowed to create new companies then ownership will be transfered. You just need to specify another user's ID. This action is not revertable.

setFormStore('userUuid', value)} + labelText="Target user's ID" + value={formStore.userId} + onChange={(value) => setFormStore('userId', value)} />
diff --git a/app/javascript/components/compounds/CompanyEdit/requests/removeExcludeGroupRequest.jsx b/app/javascript/components/compounds/CompanyEdit/requests/removeExcludeGroupRequest.jsx index 8eabd384..fbeca7cc 100644 --- a/app/javascript/components/compounds/CompanyEdit/requests/removeExcludeGroupRequest.jsx +++ b/app/javascript/components/compounds/CompanyEdit/requests/removeExcludeGroupRequest.jsx @@ -1,8 +1,8 @@ import { apiRequest, csrfToken } from '../../../../helpers'; -export const removeExcludeGroupRequest = async (uuid) => { +export const removeExcludeGroupRequest = async (id) => { return await apiRequest({ - url: `/frontend/excludes/groups/${uuid}.json`, + url: `/frontend/excludes/groups/${id}.json`, options: { method: 'DELETE', headers: { diff --git a/app/javascript/components/compounds/CompanyEdit/requests/removeIgnoreRequest.jsx b/app/javascript/components/compounds/CompanyEdit/requests/removeIgnoreRequest.jsx index 4941433b..488d8b36 100644 --- a/app/javascript/components/compounds/CompanyEdit/requests/removeIgnoreRequest.jsx +++ b/app/javascript/components/compounds/CompanyEdit/requests/removeIgnoreRequest.jsx @@ -1,8 +1,8 @@ import { apiRequest, csrfToken } from '../../../../helpers'; -export const removeIgnoreRequest = async (uuid) => { +export const removeIgnoreRequest = async (id) => { return await apiRequest({ - url: `/frontend/entities/ignores/${uuid}.json`, + url: `/frontend/entities/ignores/${id}.json`, options: { method: 'DELETE', headers: { diff --git a/app/javascript/components/compounds/CompanyEdit/requests/removeNotificationRequest.jsx b/app/javascript/components/compounds/CompanyEdit/requests/removeNotificationRequest.jsx index 05613d2a..16a33648 100644 --- a/app/javascript/components/compounds/CompanyEdit/requests/removeNotificationRequest.jsx +++ b/app/javascript/components/compounds/CompanyEdit/requests/removeNotificationRequest.jsx @@ -1,8 +1,8 @@ import { apiRequest, csrfToken } from '../../../../helpers'; -export const removeNotificationRequest = async (uuid) => { +export const removeNotificationRequest = async (id) => { return await apiRequest({ - url: `/frontend/notifications/${uuid}.json`, + url: `/frontend/notifications/${id}.json`, options: { method: 'DELETE', headers: { diff --git a/app/javascript/components/compounds/CompanyEdit/requests/removeWebhookRequest.jsx b/app/javascript/components/compounds/CompanyEdit/requests/removeWebhookRequest.jsx index 8b3d555f..6d979dcf 100644 --- a/app/javascript/components/compounds/CompanyEdit/requests/removeWebhookRequest.jsx +++ b/app/javascript/components/compounds/CompanyEdit/requests/removeWebhookRequest.jsx @@ -1,8 +1,8 @@ import { apiRequest, csrfToken } from '../../../../helpers'; -export const removeWebhookRequest = async (uuid) => { +export const removeWebhookRequest = async (id) => { return await apiRequest({ - url: `/frontend/webhooks/${uuid}.json`, + url: `/frontend/webhooks/${id}.json`, options: { method: 'DELETE', headers: { diff --git a/app/javascript/components/compounds/CompanyEdit/requests/transferCompanyRequest.jsx b/app/javascript/components/compounds/CompanyEdit/requests/transferCompanyRequest.jsx index 52848ecb..73e32ee5 100644 --- a/app/javascript/components/compounds/CompanyEdit/requests/transferCompanyRequest.jsx +++ b/app/javascript/components/compounds/CompanyEdit/requests/transferCompanyRequest.jsx @@ -1,8 +1,8 @@ import { apiRequest, csrfToken, objectKeysToSnakeCase } from '../../../../helpers'; -export const transferCompanyRequest = async (companyUuid, payload) => { +export const transferCompanyRequest = async (companyId, payload) => { return await apiRequest({ - url: `/frontend/companies/${companyUuid}/transfer.json`, + url: `/frontend/companies/${companyId}/transfer.json`, options: { method: 'POST', headers: { diff --git a/app/javascript/components/compounds/CompanyEdit/requests/updateCompanyConfigurationRequest.jsx b/app/javascript/components/compounds/CompanyEdit/requests/updateCompanyConfigurationRequest.jsx index 2ac24752..e3999f89 100644 --- a/app/javascript/components/compounds/CompanyEdit/requests/updateCompanyConfigurationRequest.jsx +++ b/app/javascript/components/compounds/CompanyEdit/requests/updateCompanyConfigurationRequest.jsx @@ -1,8 +1,8 @@ import { apiRequest, csrfToken } from '../../../../helpers'; -export const updateCompanyConfigurationRequest = async (companyUuid, payload) => { +export const updateCompanyConfigurationRequest = async (companyId, payload) => { return await apiRequest({ - url: `/frontend/companies/${companyUuid}/configuration.json`, + url: `/frontend/companies/${companyId}/configuration.json`, options: { method: 'PATCH', headers: { diff --git a/app/javascript/components/compounds/Profile/ProfilePrivacy.jsx b/app/javascript/components/compounds/Profile/ProfilePrivacy.jsx index 0488352c..2ebbf205 100644 --- a/app/javascript/components/compounds/Profile/ProfilePrivacy.jsx +++ b/app/javascript/components/compounds/Profile/ProfilePrivacy.jsx @@ -44,18 +44,18 @@ export const ProfilePrivacy = (props) => { } } - const onInviteRemove = async (uuid) => { - const result = await removeInviteRequest(uuid); + const onInviteRemove = async (id) => { + const result = await removeInviteRequest(id); if (result.errors) renderErrors(result.errors); - else setPageState({ ...pageState, invites: pageState.invites.filter((item) => item.uuid !== uuid) }); + else setPageState({ ...pageState, invites: pageState.invites.filter((item) => item.id !== id) }); } - const onAcceptedInviteRemove = async (uuid) => { - const result = await removeAcceptedInviteRequest(uuid); + const onAcceptedInviteRemove = async (id) => { + const result = await removeAcceptedInviteRequest(id); if (result.errors) renderErrors(result.errors); - else setPageState({ ...pageState, acceptedInvites: pageState.acceptedInvites.filter((item) => item.uuid !== uuid) }); + else setPageState({ ...pageState, acceptedInvites: pageState.acceptedInvites.filter((item) => item.id !== id) }); } const onApiAccessTokenCreate = async () => { @@ -69,7 +69,7 @@ export const ProfilePrivacy = (props) => { const result = await removeApiAccessTokenRequest(id); if (result.errors) renderErrors(result.errors); - else setPageState({ ...pageState, apiAccessTokens: pageState.apiAccessTokens.filter((item) => item.uuid !== id) }) + else setPageState({ ...pageState, apiAccessTokens: pageState.apiAccessTokens.filter((item) => item.id !== id) }) } return ( @@ -92,7 +92,7 @@ export const ProfilePrivacy = (props) => {

onApiAccessTokenRemove(apiAccessToken.uuid)} + onClick={() => onApiAccessTokenRemove(apiAccessToken.id)} >X

@@ -125,7 +125,7 @@ export const ProfilePrivacy = (props) => {

onAcceptedInviteRemove(invite.uuid)} + onClick={() => onAcceptedInviteRemove(invite.id)} >X

@@ -151,7 +151,7 @@ export const ProfilePrivacy = (props) => {

onInviteRemove(invite.uuid)} + onClick={() => onInviteRemove(invite.id)} >X

diff --git a/app/javascript/components/compounds/Profile/requests/removeAcceptedInviteRequest.jsx b/app/javascript/components/compounds/Profile/requests/removeAcceptedInviteRequest.jsx index c45f0402..1009ec27 100644 --- a/app/javascript/components/compounds/Profile/requests/removeAcceptedInviteRequest.jsx +++ b/app/javascript/components/compounds/Profile/requests/removeAcceptedInviteRequest.jsx @@ -1,8 +1,8 @@ import { apiRequest, csrfToken } from '../../../../helpers'; -export const removeAcceptedInviteRequest = async (uuid) => { +export const removeAcceptedInviteRequest = async (id) => { return await apiRequest({ - url: `/frontend/companies/users/${uuid}.json`, + url: `/frontend/companies/users/${id}.json`, options: { method: 'DELETE', headers: { diff --git a/app/javascript/components/compounds/Profile/requests/removeInviteRequest.jsx b/app/javascript/components/compounds/Profile/requests/removeInviteRequest.jsx index 62d4ff05..cd49df02 100644 --- a/app/javascript/components/compounds/Profile/requests/removeInviteRequest.jsx +++ b/app/javascript/components/compounds/Profile/requests/removeInviteRequest.jsx @@ -1,8 +1,8 @@ import { apiRequest, csrfToken } from '../../../../helpers'; -export const removeInviteRequest = async (uuid) => { +export const removeInviteRequest = async (id) => { return await apiRequest({ - url: `/frontend/invites/${uuid}.json`, + url: `/frontend/invites/${id}.json`, options: { method: 'DELETE', headers: { diff --git a/app/javascript/components/compounds/Repository/Repository.jsx b/app/javascript/components/compounds/Repository/Repository.jsx index ba2b5cc2..742dfc6c 100644 --- a/app/javascript/components/compounds/Repository/Repository.jsx +++ b/app/javascript/components/compounds/Repository/Repository.jsx @@ -22,8 +22,8 @@ export const Repository = (props) => { if (!pageState.isExpanded) return; if (pageState.entities !== undefined) return; - const fetchInsights = async () => await fetchInsightsRequest(props.uuid); - const fetchRepositoryInsights = async () => await fetchRepositoryInsightsRequest(props.uuid); + const fetchInsights = async () => await fetchInsightsRequest(props.id); + const fetchRepositoryInsights = async () => await fetchRepositoryInsightsRequest(props.id); Promise.all([fetchInsights(), fetchRepositoryInsights()]).then( ([insightsData, repositoryInsightsData]) => { @@ -68,7 +68,7 @@ export const Repository = (props) => { return (
- +
{
Download insights PDF {editLinks()} diff --git a/app/javascript/components/compounds/Repository/RepositoryForm.jsx b/app/javascript/components/compounds/Repository/RepositoryForm.jsx index 292ebec9..46cb0bf3 100644 --- a/app/javascript/components/compounds/Repository/RepositoryForm.jsx +++ b/app/javascript/components/compounds/Repository/RepositoryForm.jsx @@ -8,7 +8,7 @@ export const RepositoryForm = (props) => { /* eslint-disable solid/reactivity */ const [formStore, setFormStore] = createStore({ - companyUuid: props.companyUuid || Object.keys(props.companies)[0], + companyId: props.companyId || Object.keys(props.companies)[0], title: '', link: '', provider: Object.keys(props.providers)[0], @@ -40,8 +40,8 @@ export const RepositoryForm = (props) => { labelText="Company" classList="w-full mb-8" items={props.companies} - selectedValue={formStore.companyUuid} - onSelect={(value) => setFormStore('companyUuid', value)} + selectedValue={formStore.companyId} + onSelect={(value) => setFormStore('companyId', value)} /> {

New Repository

Repository is just abstraction of your real repository. Link must be real, title - anything you want.

{ +export const fetchInsightsRequest = async (id) => { return await apiRequest({ - url: `/frontend/repositories/${repositoryUuid}/insights.json` + url: `/frontend/repositories/${id}/insights.json` }); } diff --git a/app/javascript/components/compounds/Repository/requests/fetchRepositoryInsightsRequest.jsx b/app/javascript/components/compounds/Repository/requests/fetchRepositoryInsightsRequest.jsx index 63f6b91d..9521e360 100644 --- a/app/javascript/components/compounds/Repository/requests/fetchRepositoryInsightsRequest.jsx +++ b/app/javascript/components/compounds/Repository/requests/fetchRepositoryInsightsRequest.jsx @@ -1,7 +1,7 @@ import { apiRequest } from '../../../../helpers'; -export const fetchRepositoryInsightsRequest = async (repositoryUuid) => { +export const fetchRepositoryInsightsRequest = async (id) => { return await apiRequest({ - url: `/frontend/repositories/${repositoryUuid}/repository_insights.json` + url: `/frontend/repositories/${id}/repository_insights.json` }); } diff --git a/app/javascript/components/compounds/Wizard/Wizard.jsx b/app/javascript/components/compounds/Wizard/Wizard.jsx index 634a402a..6d1d411d 100644 --- a/app/javascript/components/compounds/Wizard/Wizard.jsx +++ b/app/javascript/components/compounds/Wizard/Wizard.jsx @@ -13,7 +13,7 @@ export const Wizard = (props) => { companyModalIsOpen: true, repositoryModalIsOpen: false, accessTokenModalIsOpen: false, - companyUuid: null + companyId: null }); const { Modal, openModal } = createModal(); @@ -25,14 +25,14 @@ export const Wizard = (props) => { return; } - const result = await createCompanyRequest({ ...formStore, userUuid: props.accountUuid }); + const result = await createCompanyRequest({ ...formStore, userId: props.accountId }); if (result.errors) renderErrors(result.errors); else setPageState({ ...pageState, companyModalIsOpen: false, repositoryModalIsOpen: true, - companyUuid: result.result.uuid + companyId: result.result.id }); } @@ -58,7 +58,7 @@ export const Wizard = (props) => { return; } - const result = await createAccessTokenRequest({ payload: formStore, uuid: pageState.companyUuid, tokenable: 'companies' }); + const result = await createAccessTokenRequest({ payload: formStore, id: pageState.companyId, tokenable: 'companies' }); if (result.errors) renderErrors(result.errors); else window.location.reload(); @@ -82,7 +82,7 @@ export const Wizard = (props) => {

New Repository

Repository is just abstraction of your real repository. Link must be real, title - anything you want.

ID - UUID Title Repos Users @@ -14,7 +13,6 @@ <% @companies.each do |company| %> <%= company.id %> - <%= company.uuid %> <%= company.title %> <%= link_to company.repositories.size, admin_company_repositories_path(company_id: company.id), class: 'simple-link' %> <%= company.user_ids.count %> diff --git a/app/views/controllers/admin/repositories/index.html.erb b/app/views/controllers/admin/repositories/index.html.erb index 3b191710..8624299a 100644 --- a/app/views/controllers/admin/repositories/index.html.erb +++ b/app/views/controllers/admin/repositories/index.html.erb @@ -2,7 +2,6 @@ ID - UUID Title URL Access token @@ -15,7 +14,6 @@ <% @repositories.each do |repository| %> <%= repository.id %> - <%= repository.uuid %> <%= repository.title %> <%= repository.link %> <%= repository.fetch_access_token ? "#{repository.fetch_access_token.value.first(16)}-****" : '' %> diff --git a/app/views/controllers/admin/users/index.html.erb b/app/views/controllers/admin/users/index.html.erb index 1fb6ad29..2b41087e 100644 --- a/app/views/controllers/admin/users/index.html.erb +++ b/app/views/controllers/admin/users/index.html.erb @@ -2,7 +2,6 @@ ID - UUID email Work start time Work end time @@ -14,7 +13,6 @@ <% @users.each do |user| %> <%= user.id %> - <%= user.uuid %> <%= user.email %> <%= user.work_time&.starts_at %> <%= user.work_time&.ends_at %> diff --git a/app/views/controllers/web/companies/configurations/edit.html.erb b/app/views/controllers/web/companies/configurations/edit.html.erb index de6c9ec8..b27dc62c 100644 --- a/app/views/controllers/web/companies/configurations/edit.html.erb +++ b/app/views/controllers/web/companies/configurations/edit.html.erb @@ -3,28 +3,28 @@

Edit configuration

<%= js_component 'CompanyEditPrivacy', - company_uuid: @company.uuid, + company_id: @company.id, private: @current_config.private, accepted_invites: @accepted_invites, invites: @invites %> <%= js_component 'CompanyEditSettings', - company_uuid: @company.uuid, + company_id: @company.id, starts_at: @company.work_time&.starts_at, ends_at: @company.work_time&.ends_at, timezone: @company.work_time&.timezone || '0' %> <%= js_component 'CompanyEditPullRequests', - company_uuid: @company.uuid, + company_id: @company.id, fetch_period: @current_config.fetch_period, ignores: @ignores, excludes_groups: @excludes_groups %> <%= js_component 'CompanyEditInsights', - company_uuid: @company.uuid, + company_id: @company.id, is_premium: @company.premium?, insight_fields: @current_config.selected_insight_fields, main_attribute: @current_config.main_attribute, @@ -34,13 +34,13 @@ %> <%= js_component 'CompanyEditNotifications', - company_uuid: @company.uuid, + company_id: @company.id, webhooks: @webhooks, notifications: @notifications %> <%= js_component 'CompanyEditTransfer', - company_uuid: @company.uuid + company_id: @company.id %> <% end %> diff --git a/app/views/controllers/web/companies/index.html.erb b/app/views/controllers/web/companies/index.html.erb index 6d50c16b..2e4e1906 100644 --- a/app/views/controllers/web/companies/index.html.erb +++ b/app/views/controllers/web/companies/index.html.erb @@ -6,13 +6,13 @@ <%= js_component 'CompanyNewModal', accounts_for_companies: @accounts_for_companies, - account_uuid: current_user.uuid + account_id: current_user.id %> <% else %> <%= js_component 'Wizard', accounts_for_companies: @accounts_for_companies, - account_uuid: current_user.uuid, + account_id: current_user.id, providers: Repository::LINK_FORMAT_BY_PROVIDER.keys.map { |key, _| [key, key.capitalize] }.to_h %> <% end %> @@ -34,17 +34,17 @@ <% @companies.each do |company| %> <%= js_component 'Company', - uuid: company.uuid, + id: company.id, title: company.title, repositories_count: company.repositories.size, - repositories_url: company_repositories_path(company_id: company.uuid), + repositories_url: company_repositories_path(company_id: company.id), unaccessable: !company.accessable, is_private: !!company.current_config.private, main_attribute: company.current_config.main_attribute, edit_links: allowed_to?(:update?, company) ? { need_access_token: !company.all_access_tokens.exists?, - configuration: edit_company_configuration_path(company.uuid), - destroy: company_path(company.uuid) + configuration: edit_company_configuration_path(company.id), + destroy: company_path(company.id) } : nil %> <% end %> diff --git a/app/views/controllers/web/profiles/show.html.erb b/app/views/controllers/web/profiles/show.html.erb index 842232dc..dc3cfe33 100644 --- a/app/views/controllers/web/profiles/show.html.erb +++ b/app/views/controllers/web/profiles/show.html.erb @@ -1,7 +1,7 @@ <%= render PageWrappers::UserComponent.new(current_user: current_user, meta_title: 'PullKeeper | Profile') do %>

Profile

-

<%= current_user.uuid %>

+

<%= current_user.id %>

Identities

Here you can see your connected identities. You can add more or delete existing. Telegram identity is required to receive personal notifications from PullKeeper

diff --git a/app/views/controllers/web/repositories/index.html.erb b/app/views/controllers/web/repositories/index.html.erb index da326573..1dc68bb4 100644 --- a/app/views/controllers/web/repositories/index.html.erb +++ b/app/views/controllers/web/repositories/index.html.erb @@ -5,7 +5,7 @@ <% if allowed_to?(:create_repository?, current_user) %> <%= js_component 'RepositoryNewModal', - company_uuid: @company&.uuid, + company_id: @company&.id, companies: @available_companies, providers: Repository::LINK_FORMAT_BY_PROVIDER.keys.map { |key, _| [key, key.capitalize] }.to_h %> @@ -28,7 +28,7 @@ <% @repositories.each do |repository| %> <%= js_component 'Repository', - uuid: repository.uuid, + id: repository.id, avatar_url: repository.owner_avatar_url, title: repository.title, synced_at: repository.synced_at, @@ -39,7 +39,7 @@ accessable: repository.accessable, main_attribute: repository.current_config.main_attribute, edit_links: allowed_to?(:update?, repository) ? { - destroy: repository_path(repository.uuid) + destroy: repository_path(repository.id) } : nil %> <% end %> diff --git a/config/application.rb b/config/application.rb index 50282d00..64eb5db0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -54,6 +54,8 @@ class Application < Rails::Application g.stylesheets false g.javascripts false g.helper false + + g.orm :active_record, primary_key_type: :uuid end # allow encrypted and unencrypted data to co-exist diff --git a/db/migrate/20241207181125_change_primary_keys.rb b/db/migrate/20241207181125_change_primary_keys.rb new file mode 100644 index 00000000..22c8cf70 --- /dev/null +++ b/db/migrate/20241207181125_change_primary_keys.rb @@ -0,0 +1,308 @@ +class ChangePrimaryKeys < ActiveRecord::Migration[7.2] + disable_ddl_transaction! + + def up + safety_assured do + remove_foreign_key :kudos_users_achievements, column: :user_id + + rename_column :users, :id, :numeric_id + rename_column :users, :uuid, :id + change_pk(:users) + change_column_null :users, :numeric_id, true + + # vacations + rename_column :vacations, :id, :numeric_id + rename_column :vacations, :uuid, :id + change_pk(:vacations) + change_column_null :vacations, :numeric_id, true + + rename_column :vacations, :user_id, :numeric_user_id + add_column :vacations, :user_id, :uuid + add_index :vacations, :user_id, algorithm: :concurrently + + # users_sessions + rename_column :users_sessions, :id, :numeric_id + rename_column :users_sessions, :uuid, :id + change_pk(:users_sessions) + change_column_null :users_sessions, :numeric_id, true + + rename_column :users_sessions, :user_id, :numeric_user_id + add_column :users_sessions, :user_id, :uuid + add_index :users_sessions, :user_id, algorithm: :concurrently + + # subscriptions + rename_column :subscriptions, :id, :numeric_id + rename_column :subscriptions, :uuid, :id + change_pk(:subscriptions) + change_column_null :subscriptions, :numeric_id, true + + rename_column :subscriptions, :user_id, :numeric_user_id + add_column :subscriptions, :user_id, :uuid + add_index :subscriptions, :user_id, algorithm: :concurrently + + # feedbacks + rename_column :feedbacks, :id, :numeric_id + rename_column :feedbacks, :uuid, :id + change_pk(:feedbacks) + change_column_null :feedbacks, :numeric_id, true + + rename_column :feedbacks, :user_id, :numeric_user_id + add_column :feedbacks, :user_id, :uuid + add_index :feedbacks, :user_id, algorithm: :concurrently + + # api_access_tokens + rename_column :api_access_tokens, :id, :numeric_id + rename_column :api_access_tokens, :uuid, :id + change_pk(:api_access_tokens) + change_column_null :api_access_tokens, :numeric_id, true + + rename_column :api_access_tokens, :user_id, :numeric_user_id + add_column :api_access_tokens, :user_id, :uuid + add_index :api_access_tokens, :user_id, algorithm: :concurrently + + # companies + rename_column :companies, :id, :numeric_id + rename_column :companies, :uuid, :id + change_pk(:companies) + change_column_null :companies, :numeric_id, true + + rename_column :companies, :user_id, :numeric_user_id + add_column :companies, :user_id, :uuid + add_index :companies, :user_id, algorithm: :concurrently + + # webhooks + rename_column :webhooks, :id, :numeric_id + rename_column :webhooks, :uuid, :id + change_pk(:webhooks) + change_column_null :webhooks, :numeric_id, true + + rename_column :webhooks, :company_id, :numeric_company_id + add_column :webhooks, :company_id, :uuid + add_index :webhooks, [:company_id, :source, :url], unique: true, algorithm: :concurrently + + # notifications + rename_column :notifications, :id, :numeric_id + rename_column :notifications, :uuid, :id + change_pk(:notifications) + change_column_null :notifications, :numeric_id, true + + rename_column :notifications, :notifyable_id, :numeric_notifyable_id + add_column :notifications, :notifyable_id, :uuid + rename_column :notifications, :webhook_id, :numeric_webhook_id + add_column :notifications, :webhook_id, :uuid + add_index :notifications, [:webhook_id, :notification_type], unique: true, algorithm: :concurrently + add_index :notifications, [:notifyable_id, :notifyable_type], algorithm: :concurrently + + # work_times + rename_column :work_times, :id, :numeric_id + rename_column :work_times, :uuid, :id + change_pk(:work_times) + change_column_null :work_times, :numeric_id, true + + rename_column :work_times, :worktimeable_id, :numeric_worktimeable_id + add_column :work_times, :worktimeable_id, :uuid + add_index :work_times, [:worktimeable_id, :worktimeable_type], unique: true, algorithm: :concurrently + + # invites + rename_column :invites, :id, :numeric_id + rename_column :invites, :uuid, :id + change_pk(:invites) + change_column_null :invites, :numeric_id, true + + rename_column :invites, :inviteable_id, :numeric_inviteable_id + add_column :invites, :inviteable_id, :uuid + rename_column :invites, :receiver_id, :numeric_receiver_id + add_column :invites, :receiver_id, :uuid + add_index :invites, [:inviteable_id, :inviteable_type, :receiver_id], algorithm: :concurrently + + # companies_users + rename_column :companies_users, :id, :numeric_id + rename_column :companies_users, :uuid, :id + change_pk(:companies_users) + change_column_null :companies_users, :numeric_id, true + + rename_column :companies_users, :user_id, :numeric_user_id + add_column :companies_users, :user_id, :uuid + rename_column :companies_users, :company_id, :numeric_company_id + add_column :companies_users, :company_id, :uuid + rename_column :companies_users, :invite_id, :numeric_invite_id + add_column :companies_users, :invite_id, :uuid + add_index :companies_users, [:company_id, :user_id], unique: true, algorithm: :concurrently + add_index :companies_users, :invite_id, algorithm: :concurrently + + # repositories + rename_column :repositories, :id, :numeric_id + rename_column :repositories, :uuid, :id + change_pk(:repositories) + change_column_null :repositories, :numeric_id, true + + rename_column :repositories, :company_id, :numeric_company_id + add_column :repositories, :company_id, :uuid + add_index :repositories, :company_id, algorithm: :concurrently + + # access_tokens + rename_column :access_tokens, :id, :numeric_id + rename_column :access_tokens, :uuid, :id + change_pk(:access_tokens) + change_column_null :access_tokens, :numeric_id, true + + rename_column :access_tokens, :tokenable_id, :numeric_tokenable_id + add_column :access_tokens, :tokenable_id, :uuid + add_index :access_tokens, [:tokenable_id, :tokenable_type], unique: true, algorithm: :concurrently + + # identities + rename_column :identities, :id, :numeric_id + rename_column :identities, :uuid, :id + change_pk(:identities) + change_column_null :identities, :numeric_id, true + + rename_column :identities, :user_id, :numeric_user_id + add_column :identities, :user_id, :uuid + add_index :identities, :user_id, algorithm: :concurrently + + # entities + rename_column :entities, :id, :numeric_id + rename_column :entities, :uuid, :id + change_pk(:entities) + change_column_null :entities, :numeric_id, true + + rename_column :entities, :identity_id, :numeric_identity_id + add_column :entities, :identity_id, :uuid + add_index :entities, :identity_id, algorithm: :concurrently + + # insights + rename_column :insights, :id, :numeric_id + rename_column :insights, :uuid, :id + change_pk(:insights) + change_column_null :insights, :numeric_id, true + + rename_column :insights, :insightable_id, :numeric_insightable_id + add_column :insights, :insightable_id, :uuid + rename_column :insights, :entity_id, :numeric_entity_id + add_column :insights, :entity_id, :uuid + add_index :insights, [:insightable_id, :insightable_type], algorithm: :concurrently + add_index :insights, :entity_id, algorithm: :concurrently + + # subscribers + rename_column :subscribers, :id, :numeric_id + rename_column :subscribers, :uuid, :id + change_pk(:subscribers) + change_column_null :subscribers, :numeric_id, true + + # ignores + rename_column :ignores, :id, :numeric_id + rename_column :ignores, :uuid, :id + change_pk(:ignores) + change_column_null :ignores, :numeric_id, true + + rename_column :ignores, :insightable_id, :numeric_insightable_id + add_column :ignores, :insightable_id, :uuid + add_index :ignores, [:insightable_id, :insightable_type, :entity_value], unique: true, algorithm: :concurrently + + # excludes_groups + rename_column :excludes_groups, :id, :numeric_id + rename_column :excludes_groups, :uuid, :id + change_pk(:excludes_groups) + change_column_null :excludes_groups, :numeric_id, true + + rename_column :excludes_groups, :insightable_id, :numeric_insightable_id + add_column :excludes_groups, :insightable_id, :uuid + add_index :excludes_groups, [:insightable_id, :insightable_type], algorithm: :concurrently + + # excludes_rules + rename_column :excludes_rules, :id, :numeric_id + rename_column :excludes_rules, :uuid, :id + change_pk(:excludes_rules) + change_column_null :excludes_rules, :numeric_id, true + + rename_column :excludes_rules, :excludes_group_id, :numeric_excludes_group_id + add_column :excludes_rules, :excludes_group_id, :uuid + add_index :excludes_rules, :excludes_group_id + + # issues + rename_column :issues, :id, :numeric_id + rename_column :issues, :uuid, :id + change_pk(:issues) + change_column_null :issues, :numeric_id, true + + rename_column :issues, :repository_id, :numeric_repository_id + add_column :issues, :repository_id, :uuid + add_index :issues, :repository_id + + # issue_comments + rename_column :issue_comments, :id, :numeric_id + rename_column :issue_comments, :uuid, :id + change_pk(:issue_comments) + change_column_null :issue_comments, :numeric_id, true + + rename_column :issue_comments, :issue_id, :numeric_issue_id + add_column :issue_comments, :issue_id, :uuid + add_index :issue_comments, :issue_id + + # repositories_insights + rename_column :repositories_insights, :id, :numeric_id + rename_column :repositories_insights, :uuid, :id + change_pk(:repositories_insights) + change_column_null :repositories_insights, :numeric_id, true + + rename_column :repositories_insights, :repository_id, :numeric_repository_id + add_column :repositories_insights, :repository_id, :uuid + add_index :repositories_insights, :repository_id + + # pull_requests + rename_column :pull_requests, :id, :numeric_id + rename_column :pull_requests, :uuid, :id + change_pk(:pull_requests) + change_column_null :pull_requests, :numeric_id, true + + rename_column :pull_requests, :repository_id, :numeric_repository_id + add_column :pull_requests, :repository_id, :uuid + rename_column :pull_requests, :entity_id, :numeric_entity_id + add_column :pull_requests, :entity_id, :uuid + add_index :pull_requests, :repository_id + add_index :pull_requests, :entity_id + + # pull_requests_comments + rename_column :pull_requests_comments, :id, :numeric_id + rename_column :pull_requests_comments, :uuid, :id + change_pk(:pull_requests_comments) + change_column_null :pull_requests_comments, :numeric_id, true + + rename_column :pull_requests_comments, :pull_request_id, :numeric_pull_request_id + add_column :pull_requests_comments, :pull_request_id, :uuid + rename_column :pull_requests_comments, :entity_id, :numeric_entity_id + add_column :pull_requests_comments, :entity_id, :uuid + add_index :pull_requests_comments, :pull_request_id + add_index :pull_requests_comments, :entity_id + + # pull_requests_reviews + rename_column :pull_requests_reviews, :id, :numeric_id + rename_column :pull_requests_reviews, :uuid, :id + change_pk(:pull_requests_reviews) + change_column_null :pull_requests_reviews, :numeric_id, true + + rename_column :pull_requests_reviews, :pull_request_id, :numeric_pull_request_id + add_column :pull_requests_reviews, :pull_request_id, :uuid + rename_column :pull_requests_reviews, :entity_id, :numeric_entity_id + add_column :pull_requests_reviews, :entity_id, :uuid + add_index :pull_requests_reviews, :pull_request_id + add_index :pull_requests_reviews, :entity_id + + # kudos_users_achievements + rename_column :kudos_users_achievements, :user_id, :numeric_user_id + add_column :kudos_users_achievements, :user_id, :uuid + add_index :kudos_users_achievements, :user_id + end + end + + def down; end + + def change_pk(table) + execute "ALTER TABLE #{table} DROP CONSTRAINT #{table}_pkey;" + execute "ALTER TABLE #{table} ADD PRIMARY KEY (id);" + execute "ALTER TABLE ONLY #{table} ALTER COLUMN numeric_id DROP DEFAULT;" + execute "DROP SEQUENCE IF EXISTS #{table}_id_seq" + + change_column_null table, :numeric_id, true + end +end diff --git a/db/migrate/20241207182227_backfill_data.rb b/db/migrate/20241207182227_backfill_data.rb new file mode 100644 index 00000000..5c2c6d06 --- /dev/null +++ b/db/migrate/20241207182227_backfill_data.rb @@ -0,0 +1,209 @@ +class BackfillData < ActiveRecord::Migration[7.2] + disable_ddl_transaction! + + def up + User::Vacation.find_each do |item| + item.update!(user_id: User.find_by(numeric_id: item.numeric_user_id).id) + end + + User::Session.find_each do |item| + item.update!(user_id: User.find_by(numeric_id: item.numeric_user_id).id) + end + + User::Subscription.find_each do |item| + item.update!(user_id: User.find_by(numeric_id: item.numeric_user_id).id) + end + + User::Feedback.find_each do |item| + item.update!(user_id: User.find_by(numeric_id: item.numeric_user_id).id) + end + + ApiAccessToken.find_each do |item| + item.update!(user_id: User.find_by(numeric_id: item.numeric_user_id).id) + end + + Company.find_each do |item| + item.update!(user_id: User.find_by(numeric_id: item.numeric_user_id).id) + end + + Webhook.find_each do |item| + item.update!(company_id: Company.find_by(numeric_id: item.numeric_company_id).id) + end + + Notification.find_each do |item| + item.update!( + notifyable_id: item.notifyable_type.constantize.find_by(numeric_id: item.numeric_notifyable_id).id, + webhook_id: Webhook.find_by(numeric_id: item.numeric_webhook_id).id + ) + end + + WorkTime.find_each do |item| + item.update!( + worktimeable_id: item.worktimeable_type.constantize.find_by(numeric_id: item.numeric_worktimeable_id).id + ) + end + + Invite.find_each do |item| + item.update!( + inviteable_id: item.inviteable_type.constantize.find_by(numeric_id: item.numeric_inviteable_id).id, + receiver_id: User.find_by(numeric_id: item.numeric_receiver_id)&.id + ) + end + + Companies::User.find_each do |item| + item.update!( + company_id: Company.find_by(numeric_id: item.numeric_company_id).id, + user_id: User.find_by(numeric_id: item.numeric_user_id).id, + invite_id: Invite.find_by(numeric_id: item.numeric_invite_id).id + ) + end + + Repository.find_each do |item| + item.update!(company_id: Company.find_by(numeric_id: item.numeric_company_id).id) + end + + AccessToken.find_each do |item| + item.update!( + tokenable_id: item.tokenable_type.constantize.find_by(numeric_id: item.numeric_tokenable_id).id + ) + end + + Identity.find_each do |item| + item.update!(user_id: User.find_by(numeric_id: item.numeric_user_id).id) + end + + Entity.find_each do |item| + item.update!(identity_id: User.find_by(numeric_id: item.numeric_identity_id)&.id) + end + + Insight.find_each do |item| + item.update!( + insightable_id: item.insightable_type.constantize.find_by(numeric_id: item.numeric_insightable_id).id, + entity_id: Entity.find_by(numeric_id: item.numeric_entity_id).id + ) + end + + Entity::Ignore.find_each do |item| + item.update!( + insightable_id: item.insightable_type.constantize.find_by(numeric_id: item.numeric_insightable_id).id + ) + end + + Excludes::Group.find_each do |item| + item.update!( + insightable_id: item.insightable_type.constantize.find_by(numeric_id: item.numeric_insightable_id).id + ) + end + + Excludes::Rule.find_each do |item| + item.update!(excludes_group_id: Excludes::Group.find_by(numeric_id: item.numeric_excludes_group_id).id) + end + + Issue.find_each do |item| + item.update!(repository_id: Repository.find_by(numeric_id: item.numeric_repository_id).id) + end + + Issue::Comment.find_each do |item| + item.update!(issue_id: Issue.find_by(numeric_id: item.numeric_issue_id).id) + end + + Repositories::Insight.find_each do |item| + item.update!(repository_id: Repository.find_by(numeric_id: item.numeric_repository_id).id) + end + + PullRequest.find_each do |item| + item.update!( + repository_id: Repository.find_by(numeric_id: item.numeric_repository_id).id, + entity_id: Entity.find_by(numeric_id: item.numeric_entity_id).id + ) + end + + PullRequest::Comment.find_each do |item| + item.update!( + pull_request_id: PullRequest.find_by(numeric_id: item.numeric_pull_request_id).id, + entity_id: Entity.find_by(numeric_id: item.numeric_entity_id).id + ) + end + + PullRequest::Review.find_each do |item| + item.update!( + pull_request_id: PullRequest.find_by(numeric_id: item.numeric_pull_request_id).id, + entity_id: Entity.find_by(numeric_id: item.numeric_entity_id).id + ) + end + + Kudos::Users::Achievement.find_each do |item| + item.update!(user_id: User.find_by(numeric_id: item.numeric_user_id).id) + end + + safety_assured do + change_column_null :vacations, :user_id, false + change_column_null :users_sessions, :user_id, false + change_column_null :subscriptions, :user_id, false + change_column_null :feedbacks, :user_id, false + change_column_null :api_access_tokens, :user_id, false + change_column_null :companies, :user_id, false + change_column_null :companies_users, :company_id, false + change_column_null :companies_users, :user_id, false + change_column_null :companies_users, :invite_id, false + change_column_null :webhooks, :company_id, false + change_column_null :notifications, :notifyable_id, false + change_column_null :notifications, :webhook_id, false + change_column_null :work_times, :worktimeable_id, false + change_column_null :invites, :inviteable_id, false + change_column_null :repositories, :company_id, false + change_column_null :access_tokens, :tokenable_id, false + change_column_null :identities, :user_id, false + change_column_null :insights, :insightable_id, false + change_column_null :insights, :entity_id, false + change_column_null :ignores, :insightable_id, false + change_column_null :excludes_groups, :insightable_id, false + change_column_null :excludes_rules, :excludes_group_id, false + change_column_null :issues, :repository_id, false + change_column_null :issue_comments, :issue_id, false + change_column_null :repositories_insights, :repository_id, false + change_column_null :pull_requests, :repository_id, false + change_column_null :pull_requests, :entity_id, false + change_column_null :pull_requests_comments, :pull_request_id, false + change_column_null :pull_requests_comments, :entity_id, false + change_column_null :pull_requests_reviews, :pull_request_id, false + change_column_null :pull_requests_reviews, :entity_id, false + change_column_null :kudos_users_achievements, :user_id, false + + change_column_null :vacations, :numeric_user_id, true + change_column_null :users_sessions, :numeric_user_id, true + change_column_null :subscriptions, :numeric_user_id, true + change_column_null :feedbacks, :numeric_user_id, true + change_column_null :api_access_tokens, :numeric_user_id, true + change_column_null :companies, :numeric_user_id, true + change_column_null :companies_users, :numeric_company_id, true + change_column_null :companies_users, :numeric_user_id, true + change_column_null :companies_users, :numeric_invite_id, true + change_column_null :webhooks, :numeric_company_id, true + change_column_null :notifications, :numeric_notifyable_id, true + change_column_null :notifications, :numeric_webhook_id, true + change_column_null :work_times, :numeric_worktimeable_id, true + change_column_null :invites, :numeric_inviteable_id, true + change_column_null :repositories, :numeric_company_id, true + change_column_null :access_tokens, :numeric_tokenable_id, true + change_column_null :identities, :numeric_user_id, true + change_column_null :insights, :numeric_insightable_id, true + change_column_null :insights, :numeric_entity_id, true + change_column_null :ignores, :numeric_insightable_id, true + change_column_null :excludes_groups, :numeric_insightable_id, true + change_column_null :excludes_rules, :numeric_excludes_group_id, true + change_column_null :issues, :numeric_repository_id, true + change_column_null :issue_comments, :numeric_issue_id, true + change_column_null :repositories_insights, :numeric_repository_id, true + change_column_null :pull_requests, :numeric_repository_id, true + change_column_null :pull_requests, :numeric_entity_id, true + change_column_null :pull_requests_comments, :numeric_pull_request_id, true + change_column_null :pull_requests_comments, :numeric_entity_id, true + change_column_null :pull_requests_reviews, :numeric_pull_request_id, true + change_column_null :pull_requests_reviews, :numeric_entity_id, true + change_column_null :kudos_users_achievements, :numeric_user_id, true + end + end + + def down; end +end diff --git a/db/structure.sql b/db/structure.sql index 33f6b341..842c6151 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -267,69 +267,33 @@ $$; -- CREATE TABLE public.access_tokens ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - tokenable_id bigint NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_tokenable_id bigint, tokenable_type character varying NOT NULL, value text NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, - expired_at timestamp(6) without time zone + expired_at timestamp(6) without time zone, + tokenable_id uuid NOT NULL ); --- --- Name: access_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.access_tokens_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: access_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.access_tokens_id_seq OWNED BY public.access_tokens.id; - - -- -- Name: api_access_tokens; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.api_access_tokens ( - id bigint NOT NULL, - user_id bigint NOT NULL, + numeric_id bigint, + numeric_user_id bigint, value text NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL + id uuid DEFAULT gen_random_uuid() NOT NULL, + user_id uuid NOT NULL ); --- --- Name: api_access_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.api_access_tokens_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: api_access_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.api_access_tokens_id_seq OWNED BY public.api_access_tokens.id; - - -- -- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - -- @@ -347,9 +311,9 @@ CREATE TABLE public.ar_internal_metadata ( -- CREATE TABLE public.companies ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - user_id bigint NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_user_id bigint, title character varying NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, @@ -357,64 +321,30 @@ CREATE TABLE public.companies ( configuration jsonb DEFAULT '{}'::jsonb NOT NULL, accessable boolean DEFAULT true NOT NULL, not_accessable_ticks integer DEFAULT 0 NOT NULL, - config jsonb DEFAULT '{}'::jsonb NOT NULL + config jsonb DEFAULT '{}'::jsonb NOT NULL, + user_id uuid NOT NULL ); --- --- Name: companies_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.companies_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: companies_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.companies_id_seq OWNED BY public.companies.id; - - -- -- Name: companies_users; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.companies_users ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - company_id bigint NOT NULL, - user_id bigint NOT NULL, - invite_id bigint NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_company_id bigint, + numeric_user_id bigint, + numeric_invite_id bigint, access integer DEFAULT 0 NOT NULL, created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL + updated_at timestamp(6) without time zone NOT NULL, + user_id uuid NOT NULL, + company_id uuid NOT NULL, + invite_id uuid NOT NULL ); --- --- Name: companies_users_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.companies_users_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: companies_users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.companies_users_id_seq OWNED BY public.companies_users.id; - - -- -- Name: emailbutler_messages; Type: TABLE; Schema: public; Owner: - -- @@ -458,38 +388,20 @@ ALTER SEQUENCE public.emailbutler_messages_id_seq OWNED BY public.emailbutler_me -- CREATE TABLE public.entities ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, external_id character varying NOT NULL, provider integer DEFAULT 0 NOT NULL, login character varying, avatar_url character varying, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, - identity_id bigint, - html_url character varying + numeric_identity_id bigint, + html_url character varying, + identity_id uuid ); --- --- Name: entities_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.entities_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: entities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.entities_id_seq OWNED BY public.entities.id; - - -- -- Name: event_store_events; Type: TABLE; Schema: public; Owner: - -- @@ -561,47 +473,30 @@ ALTER SEQUENCE public.event_store_events_in_streams_id_seq OWNED BY public.event -- CREATE TABLE public.excludes_groups ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - insightable_id bigint NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_insightable_id bigint, insightable_type character varying NOT NULL, created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL + updated_at timestamp(6) without time zone NOT NULL, + insightable_id uuid NOT NULL ); --- --- Name: excludes_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.excludes_groups_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: excludes_groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.excludes_groups_id_seq OWNED BY public.excludes_groups.id; - - -- -- Name: excludes_rules; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.excludes_rules ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - excludes_group_id bigint NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_excludes_group_id bigint, target integer NOT NULL, condition integer NOT NULL, value character varying NOT NULL, created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL + updated_at timestamp(6) without time zone NOT NULL, + excludes_group_id uuid NOT NULL ); @@ -626,140 +521,67 @@ COMMENT ON COLUMN public.excludes_rules.condition IS 'Condition for exclude rule COMMENT ON COLUMN public.excludes_rules.value IS 'Value for comparison'; --- --- Name: excludes_rules_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.excludes_rules_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: excludes_rules_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.excludes_rules_id_seq OWNED BY public.excludes_rules.id; - - -- -- Name: feedbacks; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.feedbacks ( - id bigint NOT NULL, - user_id bigint NOT NULL, + numeric_id bigint, + numeric_user_id bigint, title character varying, description text NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, email text, answerable boolean DEFAULT false NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL + id uuid DEFAULT gen_random_uuid() NOT NULL, + user_id uuid NOT NULL ); --- --- Name: feedbacks_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.feedbacks_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: feedbacks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.feedbacks_id_seq OWNED BY public.feedbacks.id; - - -- -- Name: identities; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.identities ( - id bigint NOT NULL, - user_id bigint NOT NULL, + numeric_id bigint, + numeric_user_id bigint, uid character varying NOT NULL, provider integer DEFAULT 0 NOT NULL, email text, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, login character varying, - uuid uuid DEFAULT gen_random_uuid() NOT NULL + id uuid DEFAULT gen_random_uuid() NOT NULL, + user_id uuid NOT NULL ); --- --- Name: identities_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.identities_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: identities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.identities_id_seq OWNED BY public.identities.id; - - -- -- Name: ignores; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.ignores ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - insightable_id bigint NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_insightable_id bigint, insightable_type character varying NOT NULL, entity_value character varying NOT NULL, created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL + updated_at timestamp(6) without time zone NOT NULL, + insightable_id uuid NOT NULL ); --- --- Name: ignores_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.ignores_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: ignores_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.ignores_id_seq OWNED BY public.ignores.id; - - -- -- Name: insights; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.insights ( - id bigint NOT NULL, - insightable_id bigint NOT NULL, + numeric_id bigint, + numeric_insightable_id bigint, insightable_type character varying NOT NULL, - entity_id bigint NOT NULL, + numeric_entity_id bigint, comments_count integer DEFAULT 0, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, @@ -779,7 +601,9 @@ CREATE TABLE public.insights ( bad_reviews_count integer DEFAULT 0 NOT NULL, conventional_comments_count integer DEFAULT 0, time_since_last_open_pull_seconds integer DEFAULT 0, - uuid uuid DEFAULT gen_random_uuid() NOT NULL + id uuid DEFAULT gen_random_uuid() NOT NULL, + insightable_id uuid NOT NULL, + entity_id uuid NOT NULL ); @@ -797,74 +621,39 @@ COMMENT ON COLUMN public.insights.hidden IS 'Flag for hiding insights, if true - COMMENT ON COLUMN public.insights.time_since_last_open_pull_seconds IS 'Time since last open pull request'; --- --- Name: insights_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.insights_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: insights_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.insights_id_seq OWNED BY public.insights.id; - - -- -- Name: invites; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.invites ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - inviteable_id bigint NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_inviteable_id bigint, inviteable_type character varying NOT NULL, - receiver_id bigint, + numeric_receiver_id bigint, email text, code character varying, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, - access integer DEFAULT 0 NOT NULL + access integer DEFAULT 0 NOT NULL, + inviteable_id uuid NOT NULL, + receiver_id uuid ); --- --- Name: invites_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.invites_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: invites_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.invites_id_seq OWNED BY public.invites.id; - - -- -- Name: issue_comments; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.issue_comments ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - issue_id bigint NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_issue_id bigint, external_id character varying NOT NULL, comment_created_at timestamp(6) without time zone, created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL + updated_at timestamp(6) without time zone NOT NULL, + issue_id uuid NOT NULL ); @@ -882,60 +671,23 @@ COMMENT ON TABLE public.issue_comments IS 'Comments of issue'; COMMENT ON COLUMN public.issue_comments.comment_created_at IS 'Time of creating comment in issue'; --- --- Name: issue_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.issue_comments_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: issue_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.issue_comments_id_seq OWNED BY public.issue_comments.id; - - -- -- Name: issues; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.issues ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - repository_id bigint NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_repository_id bigint, opened_at timestamp(6) without time zone, closed_at timestamp(6) without time zone, issue_number integer, created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL + updated_at timestamp(6) without time zone NOT NULL, + repository_id uuid NOT NULL ); --- --- Name: issues_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.issues_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: issues_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.issues_id_seq OWNED BY public.issues.id; - - -- -- Name: kudos_achievement_groups; Type: TABLE; Schema: public; Owner: - -- @@ -1013,7 +765,7 @@ ALTER SEQUENCE public.kudos_achievements_id_seq OWNED BY public.kudos_achievemen CREATE TABLE public.kudos_users_achievements ( id bigint NOT NULL, - user_id bigint NOT NULL, + numeric_user_id bigint, kudos_achievement_id bigint NOT NULL, notified boolean DEFAULT false NOT NULL, rank integer, @@ -1021,7 +773,8 @@ CREATE TABLE public.kudos_users_achievements ( title jsonb DEFAULT '{}'::jsonb NOT NULL, description jsonb DEFAULT '{}'::jsonb NOT NULL, created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL + updated_at timestamp(6) without time zone NOT NULL, + user_id uuid NOT NULL ); @@ -1049,54 +802,39 @@ ALTER SEQUENCE public.kudos_users_achievements_id_seq OWNED BY public.kudos_user -- CREATE TABLE public.notifications ( - id bigint NOT NULL, - notifyable_id bigint NOT NULL, + numeric_id bigint, + numeric_notifyable_id bigint, notifyable_type character varying NOT NULL, notification_type integer NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - webhook_id bigint NOT NULL + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_webhook_id bigint, + notifyable_id uuid NOT NULL, + webhook_id uuid NOT NULL ); -- --- Name: notifications_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.notifications_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: notifications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.notifications_id_seq OWNED BY public.notifications.id; - - --- --- Name: pull_requests; Type: TABLE; Schema: public; Owner: - +-- Name: pull_requests; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.pull_requests ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - repository_id bigint NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_repository_id bigint, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, pull_number integer NOT NULL, pull_created_at timestamp(6) without time zone, pull_closed_at timestamp(6) without time zone, pull_merged_at timestamp(6) without time zone, - entity_id bigint NOT NULL, + numeric_entity_id bigint, pull_requests_comments_count integer DEFAULT 0 NOT NULL, changed_loc integer DEFAULT 0 NOT NULL, - last_commit_external_id character varying + last_commit_external_id character varying, + repository_id uuid NOT NULL, + entity_id uuid NOT NULL ); @@ -1112,94 +850,41 @@ COMMENT ON COLUMN public.pull_requests.changed_loc IS 'Lines Of Code changed in -- CREATE TABLE public.pull_requests_comments ( - id bigint NOT NULL, + numeric_id bigint, external_id character varying NOT NULL, comment_created_at timestamp(6) without time zone NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, - pull_request_id bigint NOT NULL, - entity_id bigint NOT NULL, + numeric_pull_request_id bigint, + numeric_entity_id bigint, parsed_body jsonb, - uuid uuid DEFAULT gen_random_uuid() NOT NULL + id uuid DEFAULT gen_random_uuid() NOT NULL, + pull_request_id uuid NOT NULL, + entity_id uuid NOT NULL ); --- --- Name: pull_requests_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.pull_requests_comments_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: pull_requests_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.pull_requests_comments_id_seq OWNED BY public.pull_requests_comments.id; - - --- --- Name: pull_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.pull_requests_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: pull_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.pull_requests_id_seq OWNED BY public.pull_requests.id; - - -- -- Name: pull_requests_reviews; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.pull_requests_reviews ( - id bigint NOT NULL, + numeric_id bigint, external_id character varying, review_created_at timestamp(6) without time zone, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, - pull_request_id bigint NOT NULL, - entity_id bigint NOT NULL, + numeric_pull_request_id bigint, + numeric_entity_id bigint, required boolean DEFAULT false NOT NULL, state integer DEFAULT 0 NOT NULL, commit_external_id character varying, - uuid uuid DEFAULT gen_random_uuid() NOT NULL + id uuid DEFAULT gen_random_uuid() NOT NULL, + pull_request_id uuid NOT NULL, + entity_id uuid NOT NULL ); --- --- Name: pull_requests_reviews_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.pull_requests_reviews_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: pull_requests_reviews_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.pull_requests_reviews_id_seq OWNED BY public.pull_requests_reviews.id; - - -- -- Name: que_jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- @@ -1254,9 +939,9 @@ WITH (fillfactor='90'); -- CREATE TABLE public.repositories ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - company_id bigint NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_company_id bigint, title character varying NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, @@ -1266,36 +951,18 @@ CREATE TABLE public.repositories ( external_id character varying, synced_at timestamp(6) without time zone, accessable boolean DEFAULT true NOT NULL, - owner_avatar_url character varying + owner_avatar_url character varying, + company_id uuid NOT NULL ); --- --- Name: repositories_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.repositories_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: repositories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.repositories_id_seq OWNED BY public.repositories.id; - - -- -- Name: repositories_insights; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.repositories_insights ( - id bigint NOT NULL, - repository_id bigint NOT NULL, + numeric_id bigint, + numeric_repository_id bigint, previous_date character varying, open_pull_requests_count integer DEFAULT 0 NOT NULL, commented_pull_requests_count integer DEFAULT 0 NOT NULL, @@ -1315,7 +982,8 @@ CREATE TABLE public.repositories_insights ( closed_issues_count integer DEFAULT 0 NOT NULL, average_issue_comment_time integer DEFAULT 0 NOT NULL, average_issue_close_time integer DEFAULT 0 NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL + id uuid DEFAULT gen_random_uuid() NOT NULL, + repository_id uuid NOT NULL ); @@ -1347,25 +1015,6 @@ COMMENT ON COLUMN public.repositories_insights.average_issue_comment_time IS 'Av COMMENT ON COLUMN public.repositories_insights.average_issue_close_time IS 'Average time until closing issue'; --- --- Name: repositories_insights_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.repositories_insights_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: repositories_insights_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.repositories_insights_id_seq OWNED BY public.repositories_insights.id; - - -- -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - -- @@ -1380,48 +1029,30 @@ CREATE TABLE public.schema_migrations ( -- CREATE TABLE public.subscribers ( - id bigint NOT NULL, + numeric_id bigint, email text NOT NULL, unsubscribe_token character varying, unsubscribed_at timestamp(6) without time zone, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL + id uuid DEFAULT gen_random_uuid() NOT NULL ); --- --- Name: subscribers_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.subscribers_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: subscribers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.subscribers_id_seq OWNED BY public.subscribers.id; - - -- -- Name: subscriptions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.subscriptions ( - id bigint NOT NULL, - user_id bigint NOT NULL, + numeric_id bigint, + numeric_user_id bigint, start_time timestamp(6) without time zone NOT NULL, end_time timestamp(6) without time zone NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, external_invoice_id character varying, - uuid uuid DEFAULT gen_random_uuid() NOT NULL + id uuid DEFAULT gen_random_uuid() NOT NULL, + user_id uuid NOT NULL ); @@ -1432,436 +1063,137 @@ CREATE TABLE public.subscriptions ( COMMENT ON COLUMN public.subscriptions.external_invoice_id IS 'Invoice ID from external system'; --- --- Name: subscriptions_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.subscriptions_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: subscriptions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.subscriptions_id_seq OWNED BY public.subscriptions.id; - - -- -- Name: users; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.users ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, email text DEFAULT ''::character varying NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, role integer DEFAULT 0 NOT NULL, work_start_time time without time zone, - work_end_time time without time zone, - work_time_zone character varying, - start_time character varying, - end_time character varying, - time_zone character varying -); - - --- --- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.users_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; - - --- --- Name: users_sessions; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.users_sessions ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - user_id bigint NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL -); - - --- --- Name: users_sessions_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.users_sessions_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: users_sessions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.users_sessions_id_seq OWNED BY public.users_sessions.id; - - --- --- Name: vacations; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.vacations ( - id bigint NOT NULL, - user_id bigint NOT NULL, - start_time timestamp(6) without time zone NOT NULL, - end_time timestamp(6) without time zone NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL -); - - --- --- Name: vacations_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.vacations_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: vacations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.vacations_id_seq OWNED BY public.vacations.id; - - --- --- Name: webhooks; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.webhooks ( - id bigint NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL, - source integer DEFAULT 0 NOT NULL, - url character varying NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL, - company_id bigint NOT NULL -); - - --- --- Name: webhooks_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.webhooks_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: webhooks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.webhooks_id_seq OWNED BY public.webhooks.id; - - --- --- Name: work_times; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.work_times ( - id bigint NOT NULL, - worktimeable_id bigint NOT NULL, - worktimeable_type character varying NOT NULL, - starts_at character varying NOT NULL, - ends_at character varying NOT NULL, - timezone character varying DEFAULT '0'::character varying NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL, - uuid uuid DEFAULT gen_random_uuid() NOT NULL -); - - --- --- Name: work_times_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.work_times_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: work_times_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.work_times_id_seq OWNED BY public.work_times.id; - - --- --- Name: access_tokens id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.access_tokens ALTER COLUMN id SET DEFAULT nextval('public.access_tokens_id_seq'::regclass); - - --- --- Name: api_access_tokens id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.api_access_tokens ALTER COLUMN id SET DEFAULT nextval('public.api_access_tokens_id_seq'::regclass); - - --- --- Name: companies id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.companies ALTER COLUMN id SET DEFAULT nextval('public.companies_id_seq'::regclass); - - --- --- Name: companies_users id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.companies_users ALTER COLUMN id SET DEFAULT nextval('public.companies_users_id_seq'::regclass); - - --- --- Name: emailbutler_messages id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.emailbutler_messages ALTER COLUMN id SET DEFAULT nextval('public.emailbutler_messages_id_seq'::regclass); - - --- --- Name: entities id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.entities ALTER COLUMN id SET DEFAULT nextval('public.entities_id_seq'::regclass); - - --- --- Name: event_store_events id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.event_store_events ALTER COLUMN id SET DEFAULT nextval('public.event_store_events_id_seq'::regclass); - - --- --- Name: event_store_events_in_streams id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.event_store_events_in_streams ALTER COLUMN id SET DEFAULT nextval('public.event_store_events_in_streams_id_seq'::regclass); - - --- --- Name: excludes_groups id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.excludes_groups ALTER COLUMN id SET DEFAULT nextval('public.excludes_groups_id_seq'::regclass); - - --- --- Name: excludes_rules id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.excludes_rules ALTER COLUMN id SET DEFAULT nextval('public.excludes_rules_id_seq'::regclass); - - --- --- Name: feedbacks id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.feedbacks ALTER COLUMN id SET DEFAULT nextval('public.feedbacks_id_seq'::regclass); - - --- --- Name: identities id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.identities ALTER COLUMN id SET DEFAULT nextval('public.identities_id_seq'::regclass); - - --- --- Name: ignores id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.ignores ALTER COLUMN id SET DEFAULT nextval('public.ignores_id_seq'::regclass); - - --- --- Name: insights id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.insights ALTER COLUMN id SET DEFAULT nextval('public.insights_id_seq'::regclass); - - --- --- Name: invites id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.invites ALTER COLUMN id SET DEFAULT nextval('public.invites_id_seq'::regclass); - - --- --- Name: issue_comments id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.issue_comments ALTER COLUMN id SET DEFAULT nextval('public.issue_comments_id_seq'::regclass); - - --- --- Name: issues id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.issues ALTER COLUMN id SET DEFAULT nextval('public.issues_id_seq'::regclass); - - --- --- Name: kudos_achievement_groups id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.kudos_achievement_groups ALTER COLUMN id SET DEFAULT nextval('public.kudos_achievement_groups_id_seq'::regclass); - - --- --- Name: kudos_achievements id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.kudos_achievements ALTER COLUMN id SET DEFAULT nextval('public.kudos_achievements_id_seq'::regclass); - - --- --- Name: kudos_users_achievements id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.kudos_users_achievements ALTER COLUMN id SET DEFAULT nextval('public.kudos_users_achievements_id_seq'::regclass); - - --- --- Name: notifications id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('public.notifications_id_seq'::regclass); - - --- --- Name: pull_requests id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.pull_requests ALTER COLUMN id SET DEFAULT nextval('public.pull_requests_id_seq'::regclass); - - --- --- Name: pull_requests_comments id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.pull_requests_comments ALTER COLUMN id SET DEFAULT nextval('public.pull_requests_comments_id_seq'::regclass); + work_end_time time without time zone, + work_time_zone character varying, + start_time character varying, + end_time character varying, + time_zone character varying +); -- --- Name: pull_requests_reviews id; Type: DEFAULT; Schema: public; Owner: - +-- Name: users_sessions; Type: TABLE; Schema: public; Owner: - -- -ALTER TABLE ONLY public.pull_requests_reviews ALTER COLUMN id SET DEFAULT nextval('public.pull_requests_reviews_id_seq'::regclass); +CREATE TABLE public.users_sessions ( + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + numeric_user_id bigint, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + user_id uuid NOT NULL +); -- --- Name: que_jobs id; Type: DEFAULT; Schema: public; Owner: - +-- Name: vacations; Type: TABLE; Schema: public; Owner: - -- -ALTER TABLE ONLY public.que_jobs ALTER COLUMN id SET DEFAULT nextval('public.que_jobs_id_seq'::regclass); +CREATE TABLE public.vacations ( + numeric_id bigint, + numeric_user_id bigint, + start_time timestamp(6) without time zone NOT NULL, + end_time timestamp(6) without time zone NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + id uuid DEFAULT gen_random_uuid() NOT NULL, + user_id uuid NOT NULL +); -- --- Name: repositories id; Type: DEFAULT; Schema: public; Owner: - +-- Name: webhooks; Type: TABLE; Schema: public; Owner: - -- -ALTER TABLE ONLY public.repositories ALTER COLUMN id SET DEFAULT nextval('public.repositories_id_seq'::regclass); +CREATE TABLE public.webhooks ( + numeric_id bigint, + id uuid DEFAULT gen_random_uuid() NOT NULL, + source integer DEFAULT 0 NOT NULL, + url character varying NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + numeric_company_id bigint, + company_id uuid NOT NULL +); -- --- Name: repositories_insights id; Type: DEFAULT; Schema: public; Owner: - +-- Name: work_times; Type: TABLE; Schema: public; Owner: - -- -ALTER TABLE ONLY public.repositories_insights ALTER COLUMN id SET DEFAULT nextval('public.repositories_insights_id_seq'::regclass); +CREATE TABLE public.work_times ( + numeric_id bigint, + numeric_worktimeable_id bigint, + worktimeable_type character varying NOT NULL, + starts_at character varying NOT NULL, + ends_at character varying NOT NULL, + timezone character varying DEFAULT '0'::character varying NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + id uuid DEFAULT gen_random_uuid() NOT NULL, + worktimeable_id uuid NOT NULL +); -- --- Name: subscribers id; Type: DEFAULT; Schema: public; Owner: - +-- Name: emailbutler_messages id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.subscribers ALTER COLUMN id SET DEFAULT nextval('public.subscribers_id_seq'::regclass); +ALTER TABLE ONLY public.emailbutler_messages ALTER COLUMN id SET DEFAULT nextval('public.emailbutler_messages_id_seq'::regclass); -- --- Name: subscriptions id; Type: DEFAULT; Schema: public; Owner: - +-- Name: event_store_events id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.subscriptions ALTER COLUMN id SET DEFAULT nextval('public.subscriptions_id_seq'::regclass); +ALTER TABLE ONLY public.event_store_events ALTER COLUMN id SET DEFAULT nextval('public.event_store_events_id_seq'::regclass); -- --- Name: users id; Type: DEFAULT; Schema: public; Owner: - +-- Name: event_store_events_in_streams id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); +ALTER TABLE ONLY public.event_store_events_in_streams ALTER COLUMN id SET DEFAULT nextval('public.event_store_events_in_streams_id_seq'::regclass); -- --- Name: users_sessions id; Type: DEFAULT; Schema: public; Owner: - +-- Name: kudos_achievement_groups id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.users_sessions ALTER COLUMN id SET DEFAULT nextval('public.users_sessions_id_seq'::regclass); +ALTER TABLE ONLY public.kudos_achievement_groups ALTER COLUMN id SET DEFAULT nextval('public.kudos_achievement_groups_id_seq'::regclass); -- --- Name: vacations id; Type: DEFAULT; Schema: public; Owner: - +-- Name: kudos_achievements id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.vacations ALTER COLUMN id SET DEFAULT nextval('public.vacations_id_seq'::regclass); +ALTER TABLE ONLY public.kudos_achievements ALTER COLUMN id SET DEFAULT nextval('public.kudos_achievements_id_seq'::regclass); -- --- Name: webhooks id; Type: DEFAULT; Schema: public; Owner: - +-- Name: kudos_users_achievements id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.webhooks ALTER COLUMN id SET DEFAULT nextval('public.webhooks_id_seq'::regclass); +ALTER TABLE ONLY public.kudos_users_achievements ALTER COLUMN id SET DEFAULT nextval('public.kudos_users_achievements_id_seq'::regclass); -- --- Name: work_times id; Type: DEFAULT; Schema: public; Owner: - +-- Name: que_jobs id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.work_times ALTER COLUMN id SET DEFAULT nextval('public.work_times_id_seq'::regclass); +ALTER TABLE ONLY public.que_jobs ALTER COLUMN id SET DEFAULT nextval('public.que_jobs_id_seq'::regclass); -- @@ -2182,6 +1514,69 @@ CREATE UNIQUE INDEX idx_on_insightable_id_insightable_type_entity_value_508616f2 CREATE INDEX idx_on_inviteable_id_inviteable_type_receiver_id_700d475c99 ON public.invites USING btree (inviteable_id, inviteable_type, receiver_id); +-- +-- Name: idx_on_numeric_company_id_numeric_user_id_7ddb80d90a; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX idx_on_numeric_company_id_numeric_user_id_7ddb80d90a ON public.companies_users USING btree (numeric_company_id, numeric_user_id); + + +-- +-- Name: idx_on_numeric_insightable_id_insightable_type_58195392fb; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_on_numeric_insightable_id_insightable_type_58195392fb ON public.excludes_groups USING btree (numeric_insightable_id, insightable_type); + + +-- +-- Name: idx_on_numeric_insightable_id_insightable_type_enti_b01b1b20a5; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX idx_on_numeric_insightable_id_insightable_type_enti_b01b1b20a5 ON public.ignores USING btree (numeric_insightable_id, insightable_type, entity_value); + + +-- +-- Name: idx_on_numeric_inviteable_id_inviteable_type_numeri_d4079f4003; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_on_numeric_inviteable_id_inviteable_type_numeri_d4079f4003 ON public.invites USING btree (numeric_inviteable_id, inviteable_type, numeric_receiver_id); + + +-- +-- Name: idx_on_numeric_notifyable_id_notifyable_type_3479f2327d; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_on_numeric_notifyable_id_notifyable_type_3479f2327d ON public.notifications USING btree (numeric_notifyable_id, notifyable_type); + + +-- +-- Name: idx_on_numeric_webhook_id_notification_type_3de333d1a8; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX idx_on_numeric_webhook_id_notification_type_3de333d1a8 ON public.notifications USING btree (numeric_webhook_id, notification_type); + + +-- +-- Name: idx_on_numeric_worktimeable_id_worktimeable_type_a086a988c8; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX idx_on_numeric_worktimeable_id_worktimeable_type_a086a988c8 ON public.work_times USING btree (numeric_worktimeable_id, worktimeable_type); + + +-- +-- Name: index_access_tokens_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_access_tokens_on_id ON public.access_tokens USING btree (id); + + +-- +-- Name: index_access_tokens_on_numeric_tokenable_id_and_tokenable_type; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_access_tokens_on_numeric_tokenable_id_and_tokenable_type ON public.access_tokens USING btree (numeric_tokenable_id, tokenable_type); + + -- -- Name: index_access_tokens_on_tokenable_id_and_tokenable_type; Type: INDEX; Schema: public; Owner: - -- @@ -2190,24 +1585,24 @@ CREATE UNIQUE INDEX index_access_tokens_on_tokenable_id_and_tokenable_type ON pu -- --- Name: index_access_tokens_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_api_access_tokens_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_access_tokens_on_uuid ON public.access_tokens USING btree (uuid); +CREATE INDEX index_api_access_tokens_on_id ON public.api_access_tokens USING btree (id); -- --- Name: index_api_access_tokens_on_user_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_api_access_tokens_on_numeric_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_api_access_tokens_on_user_id ON public.api_access_tokens USING btree (user_id); +CREATE INDEX index_api_access_tokens_on_numeric_user_id ON public.api_access_tokens USING btree (numeric_user_id); -- --- Name: index_api_access_tokens_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_api_access_tokens_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_api_access_tokens_on_uuid ON public.api_access_tokens USING btree (uuid); +CREATE INDEX index_api_access_tokens_on_user_id ON public.api_access_tokens USING btree (user_id); -- @@ -2218,17 +1613,24 @@ CREATE INDEX index_api_access_tokens_on_value ON public.api_access_tokens USING -- --- Name: index_companies_on_user_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_companies_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_companies_on_user_id ON public.companies USING btree (user_id); +CREATE UNIQUE INDEX index_companies_on_id ON public.companies USING btree (id); + + +-- +-- Name: index_companies_on_numeric_user_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_companies_on_numeric_user_id ON public.companies USING btree (numeric_user_id); -- --- Name: index_companies_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_companies_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_companies_on_uuid ON public.companies USING btree (uuid); +CREATE INDEX index_companies_on_user_id ON public.companies USING btree (user_id); -- @@ -2238,6 +1640,13 @@ CREATE UNIQUE INDEX index_companies_on_uuid ON public.companies USING btree (uui CREATE UNIQUE INDEX index_companies_users_on_company_id_and_user_id ON public.companies_users USING btree (company_id, user_id); +-- +-- Name: index_companies_users_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_companies_users_on_id ON public.companies_users USING btree (id); + + -- -- Name: index_companies_users_on_invite_id; Type: INDEX; Schema: public; Owner: - -- @@ -2246,10 +1655,10 @@ CREATE INDEX index_companies_users_on_invite_id ON public.companies_users USING -- --- Name: index_companies_users_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_companies_users_on_numeric_invite_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_companies_users_on_uuid ON public.companies_users USING btree (uuid); +CREATE INDEX index_companies_users_on_numeric_invite_id ON public.companies_users USING btree (numeric_invite_id); -- @@ -2259,6 +1668,13 @@ CREATE UNIQUE INDEX index_companies_users_on_uuid ON public.companies_users USIN CREATE UNIQUE INDEX index_emailbutler_messages_on_uuid ON public.emailbutler_messages USING btree (uuid); +-- +-- Name: index_entities_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_entities_on_id ON public.entities USING btree (id); + + -- -- Name: index_entities_on_identity_id; Type: INDEX; Schema: public; Owner: - -- @@ -2267,17 +1683,17 @@ CREATE INDEX index_entities_on_identity_id ON public.entities USING btree (ident -- --- Name: index_entities_on_provider_and_external_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_entities_on_numeric_identity_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_entities_on_provider_and_external_id ON public.entities USING btree (provider, external_id); +CREATE INDEX index_entities_on_numeric_identity_id ON public.entities USING btree (numeric_identity_id); -- --- Name: index_entities_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_entities_on_provider_and_external_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_entities_on_uuid ON public.entities USING btree (uuid); +CREATE UNIQUE INDEX index_entities_on_provider_and_external_id ON public.entities USING btree (provider, external_id); -- @@ -2330,17 +1746,17 @@ CREATE INDEX index_event_store_events_on_valid_at ON public.event_store_events U -- --- Name: index_excludes_groups_on_insightable_id_and_insightable_type; Type: INDEX; Schema: public; Owner: - +-- Name: index_excludes_groups_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_excludes_groups_on_insightable_id_and_insightable_type ON public.excludes_groups USING btree (insightable_id, insightable_type); +CREATE UNIQUE INDEX index_excludes_groups_on_id ON public.excludes_groups USING btree (id); -- --- Name: index_excludes_groups_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_excludes_groups_on_insightable_id_and_insightable_type; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_excludes_groups_on_uuid ON public.excludes_groups USING btree (uuid); +CREATE INDEX index_excludes_groups_on_insightable_id_and_insightable_type ON public.excludes_groups USING btree (insightable_id, insightable_type); -- @@ -2351,10 +1767,31 @@ CREATE INDEX index_excludes_rules_on_excludes_group_id ON public.excludes_rules -- --- Name: index_excludes_rules_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_excludes_rules_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_excludes_rules_on_id ON public.excludes_rules USING btree (id); + + +-- +-- Name: index_excludes_rules_on_numeric_excludes_group_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_excludes_rules_on_numeric_excludes_group_id ON public.excludes_rules USING btree (numeric_excludes_group_id); + + +-- +-- Name: index_feedbacks_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_excludes_rules_on_uuid ON public.excludes_rules USING btree (uuid); +CREATE UNIQUE INDEX index_feedbacks_on_id ON public.feedbacks USING btree (id); + + +-- +-- Name: index_feedbacks_on_numeric_user_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_feedbacks_on_numeric_user_id ON public.feedbacks USING btree (numeric_user_id); -- @@ -2365,10 +1802,17 @@ CREATE INDEX index_feedbacks_on_user_id ON public.feedbacks USING btree (user_id -- --- Name: index_feedbacks_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_identities_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_identities_on_id ON public.identities USING btree (id); + + +-- +-- Name: index_identities_on_numeric_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_feedbacks_on_uuid ON public.feedbacks USING btree (uuid); +CREATE INDEX index_identities_on_numeric_user_id ON public.identities USING btree (numeric_user_id); -- @@ -2386,24 +1830,24 @@ CREATE INDEX index_identities_on_user_id ON public.identities USING btree (user_ -- --- Name: index_identities_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_ignores_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_identities_on_uuid ON public.identities USING btree (uuid); +CREATE UNIQUE INDEX index_ignores_on_id ON public.ignores USING btree (id); -- --- Name: index_ignores_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_insights_on_entity_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_ignores_on_uuid ON public.ignores USING btree (uuid); +CREATE INDEX index_insights_on_entity_id ON public.insights USING btree (entity_id); -- --- Name: index_insights_on_entity_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_insights_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_insights_on_entity_id ON public.insights USING btree (entity_id); +CREATE UNIQUE INDEX index_insights_on_id ON public.insights USING btree (id); -- @@ -2414,17 +1858,31 @@ CREATE INDEX index_insights_on_insightable_id_and_insightable_type ON public.ins -- --- Name: index_insights_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_insights_on_numeric_entity_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_insights_on_numeric_entity_id ON public.insights USING btree (numeric_entity_id); + + +-- +-- Name: index_insights_on_numeric_insightable_id_and_insightable_type; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_insights_on_numeric_insightable_id_and_insightable_type ON public.insights USING btree (numeric_insightable_id, insightable_type); + + +-- +-- Name: index_invites_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_insights_on_uuid ON public.insights USING btree (uuid); +CREATE UNIQUE INDEX index_invites_on_id ON public.invites USING btree (id); -- --- Name: index_invites_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_issue_comments_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_invites_on_uuid ON public.invites USING btree (uuid); +CREATE UNIQUE INDEX index_issue_comments_on_id ON public.issue_comments USING btree (id); -- @@ -2435,24 +1893,31 @@ CREATE INDEX index_issue_comments_on_issue_id ON public.issue_comments USING btr -- --- Name: index_issue_comments_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_issue_comments_on_numeric_issue_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_issue_comments_on_uuid ON public.issue_comments USING btree (uuid); +CREATE INDEX index_issue_comments_on_numeric_issue_id ON public.issue_comments USING btree (numeric_issue_id); -- --- Name: index_issues_on_repository_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_issues_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_issues_on_repository_id ON public.issues USING btree (repository_id); +CREATE UNIQUE INDEX index_issues_on_id ON public.issues USING btree (id); + + +-- +-- Name: index_issues_on_numeric_repository_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_issues_on_numeric_repository_id ON public.issues USING btree (numeric_repository_id); -- --- Name: index_issues_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_issues_on_repository_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_issues_on_uuid ON public.issues USING btree (uuid); +CREATE INDEX index_issues_on_repository_id ON public.issues USING btree (repository_id); -- @@ -2498,17 +1963,24 @@ CREATE INDEX index_kudos_users_achievements_on_kudos_achievement_id ON public.ku -- --- Name: index_notifications_on_notifyable_id_and_notifyable_type; Type: INDEX; Schema: public; Owner: - +-- Name: index_kudos_users_achievements_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_notifications_on_notifyable_id_and_notifyable_type ON public.notifications USING btree (notifyable_id, notifyable_type); +CREATE INDEX index_kudos_users_achievements_on_user_id ON public.kudos_users_achievements USING btree (user_id); + + +-- +-- Name: index_notifications_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_notifications_on_id ON public.notifications USING btree (id); -- --- Name: index_notifications_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_notifications_on_notifyable_id_and_notifyable_type; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_notifications_on_uuid ON public.notifications USING btree (uuid); +CREATE INDEX index_notifications_on_notifyable_id_and_notifyable_type ON public.notifications USING btree (notifyable_id, notifyable_type); -- @@ -2518,6 +1990,13 @@ CREATE INDEX index_notifications_on_uuid ON public.notifications USING btree (uu CREATE UNIQUE INDEX index_notifications_on_webhook_id_and_notification_type ON public.notifications USING btree (webhook_id, notification_type); +-- +-- Name: index_pull_requests_comments_on_entity_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_pull_requests_comments_on_entity_id ON public.pull_requests_comments USING btree (entity_id); + + -- -- Name: index_pull_requests_comments_on_external_id; Type: INDEX; Schema: public; Owner: - -- @@ -2526,10 +2005,17 @@ CREATE INDEX index_pull_requests_comments_on_external_id ON public.pull_requests -- --- Name: index_pull_requests_comments_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_pull_requests_comments_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_pull_requests_comments_on_id ON public.pull_requests_comments USING btree (id); + + +-- +-- Name: index_pull_requests_comments_on_pull_request_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_pull_requests_comments_on_uuid ON public.pull_requests_comments USING btree (uuid); +CREATE INDEX index_pull_requests_comments_on_pull_request_id ON public.pull_requests_comments USING btree (pull_request_id); -- @@ -2539,6 +2025,27 @@ CREATE UNIQUE INDEX index_pull_requests_comments_on_uuid ON public.pull_requests CREATE INDEX index_pull_requests_on_entity_id ON public.pull_requests USING btree (entity_id); +-- +-- Name: index_pull_requests_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_pull_requests_on_id ON public.pull_requests USING btree (id); + + +-- +-- Name: index_pull_requests_on_numeric_entity_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_pull_requests_on_numeric_entity_id ON public.pull_requests USING btree (numeric_entity_id); + + +-- +-- Name: index_pull_requests_on_numeric_repository_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_pull_requests_on_numeric_repository_id ON public.pull_requests USING btree (numeric_repository_id); + + -- -- Name: index_pull_requests_on_repository_id; Type: INDEX; Schema: public; Owner: - -- @@ -2547,10 +2054,10 @@ CREATE INDEX index_pull_requests_on_repository_id ON public.pull_requests USING -- --- Name: index_pull_requests_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_pull_requests_reviews_on_entity_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_pull_requests_on_uuid ON public.pull_requests USING btree (uuid); +CREATE INDEX index_pull_requests_reviews_on_entity_id ON public.pull_requests_reviews USING btree (entity_id); -- @@ -2561,24 +2068,38 @@ CREATE INDEX index_pull_requests_reviews_on_external_id ON public.pull_requests_ -- --- Name: index_pull_requests_reviews_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_pull_requests_reviews_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_pull_requests_reviews_on_uuid ON public.pull_requests_reviews USING btree (uuid); +CREATE UNIQUE INDEX index_pull_requests_reviews_on_id ON public.pull_requests_reviews USING btree (id); -- --- Name: index_repositories_insights_on_repository_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_pull_requests_reviews_on_pull_request_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_repositories_insights_on_repository_id ON public.repositories_insights USING btree (repository_id); +CREATE INDEX index_pull_requests_reviews_on_pull_request_id ON public.pull_requests_reviews USING btree (pull_request_id); + + +-- +-- Name: index_repositories_insights_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_repositories_insights_on_id ON public.repositories_insights USING btree (id); + + +-- +-- Name: index_repositories_insights_on_numeric_repository_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_repositories_insights_on_numeric_repository_id ON public.repositories_insights USING btree (numeric_repository_id); -- --- Name: index_repositories_insights_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_repositories_insights_on_repository_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_repositories_insights_on_uuid ON public.repositories_insights USING btree (uuid); +CREATE INDEX index_repositories_insights_on_repository_id ON public.repositories_insights USING btree (repository_id); -- @@ -2589,10 +2110,17 @@ CREATE INDEX index_repositories_on_company_id ON public.repositories USING btree -- --- Name: index_repositories_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_repositories_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_repositories_on_id ON public.repositories USING btree (id); + + +-- +-- Name: index_repositories_on_numeric_company_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_repositories_on_uuid ON public.repositories USING btree (uuid); +CREATE INDEX index_repositories_on_numeric_company_id ON public.repositories USING btree (numeric_company_id); -- @@ -2603,24 +2131,31 @@ CREATE UNIQUE INDEX index_subscribers_on_email ON public.subscribers USING btree -- --- Name: index_subscribers_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_subscribers_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_subscribers_on_uuid ON public.subscribers USING btree (uuid); +CREATE UNIQUE INDEX index_subscribers_on_id ON public.subscribers USING btree (id); -- --- Name: index_subscriptions_on_user_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_subscriptions_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_subscriptions_on_user_id ON public.subscriptions USING btree (user_id); +CREATE UNIQUE INDEX index_subscriptions_on_id ON public.subscriptions USING btree (id); -- --- Name: index_subscriptions_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_subscriptions_on_numeric_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_subscriptions_on_uuid ON public.subscriptions USING btree (uuid); +CREATE INDEX index_subscriptions_on_numeric_user_id ON public.subscriptions USING btree (numeric_user_id); + + +-- +-- Name: index_subscriptions_on_user_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_subscriptions_on_user_id ON public.subscriptions USING btree (user_id); -- @@ -2631,10 +2166,24 @@ CREATE UNIQUE INDEX index_users_on_email ON public.users USING btree (email); -- --- Name: index_users_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_users_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_users_on_id ON public.users USING btree (id); + + +-- +-- Name: index_users_sessions_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_users_sessions_on_id ON public.users_sessions USING btree (id); + + +-- +-- Name: index_users_sessions_on_numeric_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_users_on_uuid ON public.users USING btree (uuid); +CREATE INDEX index_users_sessions_on_numeric_user_id ON public.users_sessions USING btree (numeric_user_id); -- @@ -2645,24 +2194,24 @@ CREATE INDEX index_users_sessions_on_user_id ON public.users_sessions USING btre -- --- Name: index_users_sessions_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_vacations_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_users_sessions_on_uuid ON public.users_sessions USING btree (uuid); +CREATE UNIQUE INDEX index_vacations_on_id ON public.vacations USING btree (id); -- --- Name: index_vacations_on_user_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_vacations_on_numeric_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_vacations_on_user_id ON public.vacations USING btree (user_id); +CREATE INDEX index_vacations_on_numeric_user_id ON public.vacations USING btree (numeric_user_id); -- --- Name: index_vacations_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_vacations_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_vacations_on_uuid ON public.vacations USING btree (uuid); +CREATE INDEX index_vacations_on_user_id ON public.vacations USING btree (user_id); -- @@ -2673,17 +2222,24 @@ CREATE UNIQUE INDEX index_webhooks_on_company_id_and_source_and_url ON public.we -- --- Name: index_webhooks_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_webhooks_on_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_webhooks_on_id ON public.webhooks USING btree (id); + + +-- +-- Name: index_webhooks_on_numeric_company_id_and_source_and_url; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_webhooks_on_uuid ON public.webhooks USING btree (uuid); +CREATE UNIQUE INDEX index_webhooks_on_numeric_company_id_and_source_and_url ON public.webhooks USING btree (numeric_company_id, source, url); -- --- Name: index_work_times_on_uuid; Type: INDEX; Schema: public; Owner: - +-- Name: index_work_times_on_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_work_times_on_uuid ON public.work_times USING btree (uuid); +CREATE UNIQUE INDEX index_work_times_on_id ON public.work_times USING btree (id); -- @@ -2697,7 +2253,7 @@ CREATE UNIQUE INDEX index_work_times_on_worktimeable_id_and_worktimeable_type ON -- Name: kudos_users_achievements_unique_index; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX kudos_users_achievements_unique_index ON public.kudos_users_achievements USING btree (user_id, kudos_achievement_id); +CREATE UNIQUE INDEX kudos_users_achievements_unique_index ON public.kudos_users_achievements USING btree (numeric_user_id, kudos_achievement_id); -- @@ -2742,14 +2298,6 @@ CREATE TRIGGER que_job_notify AFTER INSERT ON public.que_jobs FOR EACH ROW WHEN CREATE TRIGGER que_state_notify AFTER INSERT OR DELETE OR UPDATE ON public.que_jobs FOR EACH ROW WHEN ((NOT (COALESCE(current_setting('que.skip_notify'::text, true), ''::text) = 'true'::text))) EXECUTE FUNCTION public.que_state_notify(); --- --- Name: kudos_users_achievements fk_rails_4621adbc67; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.kudos_users_achievements - ADD CONSTRAINT fk_rails_4621adbc67 FOREIGN KEY (user_id) REFERENCES public.users(id); - - -- -- Name: kudos_users_achievements fk_rails_db98df5998; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -2773,6 +2321,8 @@ ALTER TABLE ONLY public.kudos_achievements SET search_path TO "$user", public; INSERT INTO "schema_migrations" (version) VALUES +('20241207182227'), +('20241207181125'), ('20241207174751'), ('20241207174615'), ('20241021055406'), diff --git a/engines/authkeeper/app/services/authkeeper/fetch_session_service.rb b/engines/authkeeper/app/services/authkeeper/fetch_session_service.rb index f0d5cc1b..c8952151 100644 --- a/engines/authkeeper/app/services/authkeeper/fetch_session_service.rb +++ b/engines/authkeeper/app/services/authkeeper/fetch_session_service.rb @@ -23,7 +23,7 @@ def extract_uuid(token) def find_session(payload) Authkeeper .configuration.user_session_model.constantize - .where(uuid: payload.fetch('uuid', '')).first + .where(id: payload.fetch('uuid', '')).first end end end diff --git a/engines/authkeeper/app/services/authkeeper/generate_token_service.rb b/engines/authkeeper/app/services/authkeeper/generate_token_service.rb index a4ba3da8..efb81ec6 100644 --- a/engines/authkeeper/app/services/authkeeper/generate_token_service.rb +++ b/engines/authkeeper/app/services/authkeeper/generate_token_service.rb @@ -8,7 +8,7 @@ def call(user_session:) { result: jwt_encoder.encode( payload: { - uuid: user_session.uuid + uuid: user_session.id } ) } diff --git a/engines/authkeeper/spec/services/authkeeper/fetch_session_service_spec.rb b/engines/authkeeper/spec/services/authkeeper/fetch_session_service_spec.rb index fb026ea8..df02fcc7 100644 --- a/engines/authkeeper/spec/services/authkeeper/fetch_session_service_spec.rb +++ b/engines/authkeeper/spec/services/authkeeper/fetch_session_service_spec.rb @@ -6,10 +6,10 @@ let!(:instance) { described_class.new } context 'for valid token' do - let(:token) { JwtEncoder.new.encode(payload: { uuid: session_uuid }) } + let(:token) { JwtEncoder.new.encode(payload: { uuid: session_id }) } context 'for unexisted session' do - let(:session_uuid) { 'random uuid' } + let(:session_id) { 'random uuid' } it 'does not assign user and fails', :aggregate_failures do expect(service_call[:result]).to be_nil @@ -19,7 +19,7 @@ context 'for existed session' do let(:user_session) { create :user_session } - let(:session_uuid) { user_session.uuid } + let(:session_id) { user_session.id } it 'assigns user and succeeds', :aggregate_failures do expect(service_call[:result]).to eq user_session diff --git a/spec/controllers/api/v1/companies_controller_spec.rb b/spec/controllers/api/v1/companies_controller_spec.rb index 7ec5e782..274c09b7 100644 --- a/spec/controllers/api/v1/companies_controller_spec.rb +++ b/spec/controllers/api/v1/companies_controller_spec.rb @@ -16,14 +16,14 @@ it 'returns companies data', :aggregate_failures do get :index, params: { - api_access_token: api_access_token.value, only_fields: 'uuid,title' + api_access_token: api_access_token.value, only_fields: 'id,title' } expect(response).to have_http_status :ok expect(response.parsed_body['companies'].size).to eq 1 attributes = response.parsed_body.dig('companies', 0) - expect(attributes['uuid']).not_to be_nil + expect(attributes['id']).not_to be_nil expect(attributes['title']).not_to be_nil expect(attributes['repositories_count']).to be_nil end diff --git a/spec/controllers/api/v1/insights_controller_spec.rb b/spec/controllers/api/v1/insights_controller_spec.rb index ae98e6ad..c02217ad 100644 --- a/spec/controllers/api/v1/insights_controller_spec.rb +++ b/spec/controllers/api/v1/insights_controller_spec.rb @@ -30,7 +30,7 @@ before { company.update!(user: user) } it 'returns data', :aggregate_failures do - get :index, params: { company_id: company.uuid, api_access_token: api_access_token.value } + get :index, params: { company_id: company.id, api_access_token: api_access_token.value } response_values = response.parsed_body.dig('insights', 0, 'values') @@ -55,7 +55,7 @@ end it 'returns data', :aggregate_failures do - get :index, params: { company_id: company.uuid, api_access_token: api_access_token.value } + get :index, params: { company_id: company.id, api_access_token: api_access_token.value } response_values = response.parsed_body.dig('insights', 0, 'values') @@ -72,7 +72,7 @@ end it 'returns data', :aggregate_failures do - get :index, params: { company_id: company.uuid, api_access_token: api_access_token.value } + get :index, params: { company_id: company.id, api_access_token: api_access_token.value } response_values = response.parsed_body.dig('insights', 0, 'values') @@ -93,7 +93,7 @@ before { company.update!(user: user) } it 'returns data', :aggregate_failures do - get :index, params: { repository_id: repository.uuid, api_access_token: api_access_token.value } + get :index, params: { repository_id: repository.id, api_access_token: api_access_token.value } response_values = response.parsed_body.dig('insights', 0, 'values') diff --git a/spec/controllers/frontend/access_tokens_controller_spec.rb b/spec/controllers/frontend/access_tokens_controller_spec.rb index 6a03cd0b..0a61b285 100644 --- a/spec/controllers/frontend/access_tokens_controller_spec.rb +++ b/spec/controllers/frontend/access_tokens_controller_spec.rb @@ -26,7 +26,7 @@ context 'for existing company' do let(:request) do - post :create, params: { company_id: company.uuid, access_token: { value: '' }, pullmetry_access_token: access_token } + post :create, params: { company_id: company.id, access_token: { value: '' }, pullmetry_access_token: access_token } end before { company.update!(user: user) } @@ -42,7 +42,7 @@ context 'for valid params' do let(:request) { post :create, params: { - company_id: company.uuid, + company_id: company.id, access_token: { value: 'github_pat_*****_******', expired_at: '2024-01-31 13:45' @@ -80,7 +80,7 @@ context 'for existing repository' do let(:request) do post :create, params: { - repository_id: repository.uuid, access_token: { value: '' }, pullmetry_access_token: access_token + repository_id: repository.id, access_token: { value: '' }, pullmetry_access_token: access_token } end @@ -97,7 +97,7 @@ context 'for valid params' do let(:request) { post :create, params: { - repository_id: repository.uuid, + repository_id: repository.id, access_token: { value: 'github_pat_*****_******', expired_at: '2024-01-31 13:45' diff --git a/spec/controllers/frontend/api_access_tokens_controller_spec.rb b/spec/controllers/frontend/api_access_tokens_controller_spec.rb index 67f6c49d..2f1e1ba4 100644 --- a/spec/controllers/frontend/api_access_tokens_controller_spec.rb +++ b/spec/controllers/frontend/api_access_tokens_controller_spec.rb @@ -39,7 +39,7 @@ def do_request end context 'for not own api access token' do - let(:request) { delete :destroy, params: { id: api_access_token.uuid, pullmetry_access_token: access_token } } + let(:request) { delete :destroy, params: { id: api_access_token.id, pullmetry_access_token: access_token } } it 'does not destroy api access token', :aggregate_failures do expect { request }.not_to change(ApiAccessToken, :count) @@ -48,7 +48,7 @@ def do_request end context 'for own api access token' do - let(:request) { delete :destroy, params: { id: api_access_token.uuid, pullmetry_access_token: access_token } } + let(:request) { delete :destroy, params: { id: api_access_token.id, pullmetry_access_token: access_token } } before { api_access_token.update!(user: user) } diff --git a/spec/controllers/frontend/companies/configurations_controller_spec.rb b/spec/controllers/frontend/companies/configurations_controller_spec.rb index 6b5986d8..26438d1d 100644 --- a/spec/controllers/frontend/companies/configurations_controller_spec.rb +++ b/spec/controllers/frontend/companies/configurations_controller_spec.rb @@ -21,7 +21,7 @@ context 'for not existing user company' do it 'returns forbidden error' do patch :update, params: { - company_id: company.uuid, configuration: { average_type: 'median' }, pullmetry_access_token: access_token + company_id: company.id, configuration: { average_type: 'median' }, pullmetry_access_token: access_token } expect(response).to have_http_status :forbidden @@ -34,7 +34,7 @@ context 'for invalid params' do it 'does not update configuration and redirects', :aggregate_failures do patch :update, params: { - company_id: company.uuid, configuration: { average_type: '123' }, pullmetry_access_token: access_token + company_id: company.id, configuration: { average_type: '123' }, pullmetry_access_token: access_token } config = company.reload.config @@ -47,7 +47,7 @@ context 'for valid params' do it 'updates regular configuration and redirects', :aggregate_failures do patch :update, params: { - company_id: company.uuid, configuration: { average_type: 'median' }, pullmetry_access_token: access_token + company_id: company.id, configuration: { average_type: 'median' }, pullmetry_access_token: access_token } config = company.reload.config diff --git a/spec/controllers/frontend/companies/transfers_controller_spec.rb b/spec/controllers/frontend/companies/transfers_controller_spec.rb index 88075f2f..d0265758 100644 --- a/spec/controllers/frontend/companies/transfers_controller_spec.rb +++ b/spec/controllers/frontend/companies/transfers_controller_spec.rb @@ -20,7 +20,7 @@ context 'for not existing user company' do it 'returns not found response' do - post :create, params: { company_id: company.uuid, user_uuid: 'unexisting', pullmetry_access_token: access_token } + post :create, params: { company_id: company.id, user_id: 'unexisting', pullmetry_access_token: access_token } expect(response).to have_http_status :not_found end @@ -33,7 +33,7 @@ context 'for user by self' do it 'returns not found response', :aggregate_failures do - post :create, params: { company_id: company.uuid, user_uuid: user.uuid, pullmetry_access_token: access_token } + post :create, params: { company_id: company.id, user_id: user.id, pullmetry_access_token: access_token } expect(response).to have_http_status :not_found expect(company.reload.user_id).to eq user.id @@ -42,7 +42,7 @@ context 'for another target user' do it 'updates company', :aggregate_failures do - post :create, params: { company_id: company.uuid, user_uuid: another_user.uuid, pullmetry_access_token: access_token } + post :create, params: { company_id: company.id, user_id: another_user.id, pullmetry_access_token: access_token } expect(response).to have_http_status :ok expect(company.reload.user_id).to eq another_user.id @@ -53,7 +53,7 @@ it 'does not update company', :aggregate_failures do post :create, params: { - company_id: company.uuid, user_uuid: another_user.uuid, pullmetry_access_token: access_token + company_id: company.id, user_id: another_user.id, pullmetry_access_token: access_token } expect(response).to have_http_status :ok @@ -65,7 +65,7 @@ end def do_request(access_token=nil) - post :create, params: { company_id: 'unexisting', user_uuid: 'unexisting', pullmetry_access_token: access_token } + post :create, params: { company_id: 'unexisting', user_id: 'unexisting', pullmetry_access_token: access_token } end end end diff --git a/spec/controllers/frontend/companies/users_controller_spec.rb b/spec/controllers/frontend/companies/users_controller_spec.rb index 69a72a86..b4e8501b 100644 --- a/spec/controllers/frontend/companies/users_controller_spec.rb +++ b/spec/controllers/frontend/companies/users_controller_spec.rb @@ -11,7 +11,7 @@ context 'for logged users' do let!(:company) { create :company } let!(:companies_user) { create :companies_user } - let(:request) { delete :destroy, params: { id: companies_user.uuid, pullmetry_access_token: access_token } } + let(:request) { delete :destroy, params: { id: companies_user.id, pullmetry_access_token: access_token } } context 'for company invite' do before { companies_user.invite.update!(inviteable: company) } diff --git a/spec/controllers/frontend/companies_controller_spec.rb b/spec/controllers/frontend/companies_controller_spec.rb index 0e6ee47d..73ac9d9d 100644 --- a/spec/controllers/frontend/companies_controller_spec.rb +++ b/spec/controllers/frontend/companies_controller_spec.rb @@ -30,7 +30,7 @@ context 'for external account' do let(:request) { post :create, params: { - company: { title: 'Title', user_uuid: another_user.uuid }, pullmetry_access_token: access_token + company: { title: 'Title', user_id: another_user.id }, pullmetry_access_token: access_token } } diff --git a/spec/controllers/frontend/entities/ignores_controller_spec.rb b/spec/controllers/frontend/entities/ignores_controller_spec.rb index 552a6a3c..cd6e4734 100644 --- a/spec/controllers/frontend/entities/ignores_controller_spec.rb +++ b/spec/controllers/frontend/entities/ignores_controller_spec.rb @@ -13,7 +13,7 @@ context 'for invalid company' do let(:request) { post :create, params: { - company_id: company.uuid, entity_ignore: { entity_value: '' }, pullmetry_access_token: access_token + company_id: company.id, entity_ignore: { entity_value: '' }, pullmetry_access_token: access_token } } @@ -30,7 +30,7 @@ context 'for invalid params' do let(:request) { post :create, params: { - company_id: company.uuid, entity_ignore: { entity_value: '' }, pullmetry_access_token: access_token + company_id: company.id, entity_ignore: { entity_value: '' }, pullmetry_access_token: access_token } } @@ -44,7 +44,7 @@ context 'for valid params' do let(:request) { post :create, params: { - company_id: company.uuid, entity_ignore: { entity_value: 'value' }, pullmetry_access_token: access_token + company_id: company.id, entity_ignore: { entity_value: 'value' }, pullmetry_access_token: access_token } } @@ -63,7 +63,7 @@ context 'for logged users' do let!(:ignore) { create :ignore } - let(:request) { delete :destroy, params: { id: ignore.uuid, pullmetry_access_token: access_token } } + let(:request) { delete :destroy, params: { id: ignore.id, pullmetry_access_token: access_token } } context 'for not user ignore' do it 'does not destroy ignore', :aggregate_failures do diff --git a/spec/controllers/frontend/excludes/groups_controller_spec.rb b/spec/controllers/frontend/excludes/groups_controller_spec.rb index 9012c206..e227503d 100644 --- a/spec/controllers/frontend/excludes/groups_controller_spec.rb +++ b/spec/controllers/frontend/excludes/groups_controller_spec.rb @@ -13,7 +13,7 @@ context 'for invalid company' do let(:request) { post :create, params: { - company_id: company.uuid, pullmetry_access_token: access_token + company_id: company.id, pullmetry_access_token: access_token } } @@ -30,7 +30,7 @@ context 'for valid params' do let(:request) { post :create, params: { - company_id: company.uuid, + company_id: company.id, excludes_rules: [{ target: 'title', condition: 'equal', value: 'value' }], pullmetry_access_token: access_token } @@ -51,7 +51,7 @@ context 'for logged users' do let!(:excludes_group) { create :excludes_group } - let(:request) { delete :destroy, params: { id: excludes_group.uuid, pullmetry_access_token: access_token } } + let(:request) { delete :destroy, params: { id: excludes_group.id, pullmetry_access_token: access_token } } context 'for not user excludes_group' do it 'does not destroy excludes_group', :aggregate_failures do diff --git a/spec/controllers/frontend/insights_controller_spec.rb b/spec/controllers/frontend/insights_controller_spec.rb index 1167dd6b..f220e04e 100644 --- a/spec/controllers/frontend/insights_controller_spec.rb +++ b/spec/controllers/frontend/insights_controller_spec.rb @@ -20,7 +20,7 @@ before { company.update!(user: user) } it 'returns data', :aggregate_failures do - get :index, params: { company_id: company.uuid, pullmetry_access_token: access_token, format: :json } + get :index, params: { company_id: company.id, pullmetry_access_token: access_token, format: :json } response_values = response.parsed_body.dig('insights', 0, 'values') @@ -45,7 +45,7 @@ end it 'returns data', :aggregate_failures do - get :index, params: { company_id: company.uuid, pullmetry_access_token: access_token, format: :json } + get :index, params: { company_id: company.id, pullmetry_access_token: access_token, format: :json } response_values = response.parsed_body.dig('insights', 0, 'values') @@ -62,7 +62,7 @@ end it 'returns data', :aggregate_failures do - get :index, params: { company_id: company.uuid, pullmetry_access_token: access_token, format: :json } + get :index, params: { company_id: company.id, pullmetry_access_token: access_token, format: :json } response_values = response.parsed_body.dig('insights', 0, 'values') @@ -74,7 +74,7 @@ context 'for pdf request' do it 'returns data' do - get :index, params: { company_id: company.uuid, pullmetry_access_token: access_token, format: :pdf } + get :index, params: { company_id: company.id, pullmetry_access_token: access_token, format: :pdf } expect(response).to have_http_status :ok end @@ -91,7 +91,7 @@ before { company.update!(user: user) } it 'returns data', :aggregate_failures do - get :index, params: { repository_id: repository.uuid, pullmetry_access_token: access_token, format: :json } + get :index, params: { repository_id: repository.id, pullmetry_access_token: access_token, format: :json } response_values = response.parsed_body.dig('insights', 0, 'values') diff --git a/spec/controllers/frontend/invites_controller_spec.rb b/spec/controllers/frontend/invites_controller_spec.rb index 6767d37c..9c188b17 100644 --- a/spec/controllers/frontend/invites_controller_spec.rb +++ b/spec/controllers/frontend/invites_controller_spec.rb @@ -40,7 +40,7 @@ context 'for invalid company' do let(:request) { - post :create, params: { company_id: company.uuid, invite: { email: '' }, pullmetry_access_token: access_token } + post :create, params: { company_id: company.id, invite: { email: '' }, pullmetry_access_token: access_token } } before { company.update!(user: another_user) } @@ -55,7 +55,7 @@ context 'for read access in company' do let(:request) { post :create, params: { - company_id: company.uuid, invite: { email: 'email@gmail.com' }, pullmetry_access_token: access_token + company_id: company.id, invite: { email: 'email@gmail.com' }, pullmetry_access_token: access_token } } @@ -74,7 +74,7 @@ context 'for valid company' do context 'for invalid params' do let(:request) { - post :create, params: { company_id: company.uuid, invite: { email: '' }, pullmetry_access_token: access_token } + post :create, params: { company_id: company.id, invite: { email: '' }, pullmetry_access_token: access_token } } it 'does not create invite', :aggregate_failures do @@ -87,7 +87,7 @@ context 'for valid params' do let(:request) { post :create, params: { - company_id: company.uuid, invite: { email: 'email@gmail.com' }, pullmetry_access_token: access_token + company_id: company.id, invite: { email: 'email@gmail.com' }, pullmetry_access_token: access_token } } @@ -106,7 +106,7 @@ context 'for logged users' do let!(:invite) { create :invite } - let(:request) { delete :destroy, params: { id: invite.uuid, pullmetry_access_token: access_token } } + let(:request) { delete :destroy, params: { id: invite.id, pullmetry_access_token: access_token } } context 'for user invite' do context 'for not own invite' do diff --git a/spec/controllers/frontend/notifications_controller_spec.rb b/spec/controllers/frontend/notifications_controller_spec.rb index 39789ede..d795e8b0 100644 --- a/spec/controllers/frontend/notifications_controller_spec.rb +++ b/spec/controllers/frontend/notifications_controller_spec.rb @@ -13,7 +13,7 @@ context 'for invalid company' do let(:request) { post :create, params: { - company_id: company.uuid, + company_id: company.id, webhook_id: 'unexisting', notification: { notification_type: '' }, pullmetry_access_token: access_token @@ -33,7 +33,7 @@ context 'for unexisting webhook' do let(:request) { post :create, params: { - company_id: company.uuid, + company_id: company.id, webhook_id: 'unexisting', notification: { notification_type: '' }, pullmetry_access_token: access_token @@ -50,8 +50,8 @@ context 'for invalid params' do let(:request) { post :create, params: { - company_id: company.uuid, - webhook_id: webhook.uuid, + company_id: company.id, + webhook_id: webhook.id, notification: { notification_type: '' }, pullmetry_access_token: access_token } @@ -67,8 +67,8 @@ context 'for valid params' do let(:request) { post :create, params: { - company_id: company.uuid, - webhook_id: webhook.uuid, + company_id: company.id, + webhook_id: webhook.id, notification: { notification_type: 'insights_data' }, pullmetry_access_token: access_token } @@ -101,7 +101,7 @@ context 'for logged users' do let!(:notification) { create :notification, notifyable: company } - let(:request) { delete :destroy, params: { id: notification.uuid, pullmetry_access_token: access_token } } + let(:request) { delete :destroy, params: { id: notification.id, pullmetry_access_token: access_token } } context 'for not existing notification' do let(:request) { delete :destroy, params: { id: 'unexisting', pullmetry_access_token: access_token } } diff --git a/spec/controllers/frontend/repositories/repository_insights_controller_spec.rb b/spec/controllers/frontend/repositories/repository_insights_controller_spec.rb index b0c8dafc..a691aa7f 100644 --- a/spec/controllers/frontend/repositories/repository_insights_controller_spec.rb +++ b/spec/controllers/frontend/repositories/repository_insights_controller_spec.rb @@ -19,7 +19,7 @@ before { company.update!(user: user) } it 'returns data', :aggregate_failures do - get :index, params: { repository_id: repository.uuid, pullmetry_access_token: access_token } + get :index, params: { repository_id: repository.id, pullmetry_access_token: access_token } response_values = response.parsed_body.dig('insight', 'values') diff --git a/spec/controllers/frontend/repositories_controller_spec.rb b/spec/controllers/frontend/repositories_controller_spec.rb index ff5d7364..0b88fe76 100644 --- a/spec/controllers/frontend/repositories_controller_spec.rb +++ b/spec/controllers/frontend/repositories_controller_spec.rb @@ -10,7 +10,7 @@ context 'for invalid params' do let(:request) { post :create, params: { - repository: { company_uuid: 'unexisting', title: '', link: '' }, + repository: { company_id: 'unexisting', title: '', link: '' }, pullmetry_access_token: access_token } } @@ -28,7 +28,7 @@ context 'for not existing company' do let(:request) { post :create, params: { - repository: { company_uuid: 'unexisting', title: '', link: '' }, pullmetry_access_token: access_token + repository: { company_id: 'unexisting', title: '', link: '' }, pullmetry_access_token: access_token } } @@ -42,7 +42,7 @@ context 'for existing not user company' do let(:request) { post :create, params: { - repository: { company_uuid: company.uuid, title: 'Title', link: 'nam' }, pullmetry_access_token: access_token + repository: { company_id: company.id, title: 'Title', link: 'nam' }, pullmetry_access_token: access_token } } @@ -56,7 +56,7 @@ context 'for invalid params' do let(:request) { post :create, params: { - repository: { company_uuid: company.uuid, title: '', link: '' }, pullmetry_access_token: access_token + repository: { company_id: company.id, title: '', link: '' }, pullmetry_access_token: access_token } } @@ -72,7 +72,7 @@ context 'for invalid external_id' do let(:request) { post :create, params: { - repository: { company_uuid: company.uuid, title: 'Title', link: 'link', provider: 'gitlab' }, + repository: { company_id: company.id, title: 'Title', link: 'link', provider: 'gitlab' }, pullmetry_access_token: access_token } } @@ -90,7 +90,7 @@ let(:request) { post :create, params: { repository: { - company_uuid: company.uuid, + company_id: company.id, title: 'Title', link: 'https://gitlab.com', provider: 'gitlab', @@ -112,7 +112,7 @@ let(:request) { post :create, params: { repository: { - company_uuid: company.uuid, title: 'Title', link: 'https://github.com', provider: 'github' + company_id: company.id, title: 'Title', link: 'https://github.com', provider: 'github' }, pullmetry_access_token: access_token } diff --git a/spec/controllers/frontend/webhooks_controller_spec.rb b/spec/controllers/frontend/webhooks_controller_spec.rb index 447cff62..f12e68ed 100644 --- a/spec/controllers/frontend/webhooks_controller_spec.rb +++ b/spec/controllers/frontend/webhooks_controller_spec.rb @@ -13,7 +13,7 @@ context 'for invalid company' do let(:request) { post :create, params: { - company_id: company.uuid, webhook: { source: 'custom', url: '' }, pullmetry_access_token: access_token + company_id: company.id, webhook: { source: 'custom', url: '' }, pullmetry_access_token: access_token } } @@ -30,7 +30,7 @@ context 'for invalid params' do let(:request) { post :create, params: { - company_id: company.uuid, webhook: { source: 'custom', url: '' }, pullmetry_access_token: access_token + company_id: company.id, webhook: { source: 'custom', url: '' }, pullmetry_access_token: access_token } } @@ -44,7 +44,7 @@ context 'for unexisting source' do let(:request) { post :create, params: { - company_id: company.uuid, webhook: { source: 'unexisting', url: '1123' }, pullmetry_access_token: access_token + company_id: company.id, webhook: { source: 'unexisting', url: '1123' }, pullmetry_access_token: access_token } } @@ -60,7 +60,7 @@ context 'for invalid url format' do let(:request) { post :create, params: { - company_id: company.uuid, webhook: { source: 'slack', url: '1123' }, pullmetry_access_token: access_token + company_id: company.id, webhook: { source: 'slack', url: '1123' }, pullmetry_access_token: access_token } } @@ -74,7 +74,7 @@ context 'for invalid custom url format' do let(:request) { post :create, params: { - company_id: company.uuid, webhook: { source: 'custom', url: '1123' }, pullmetry_access_token: access_token + company_id: company.id, webhook: { source: 'custom', url: '1123' }, pullmetry_access_token: access_token } } @@ -88,7 +88,7 @@ context 'for valid params' do let(:request) { post :create, params: { - company_id: company.uuid, + company_id: company.id, webhook: { source: 'slack', url: 'https://hooks.slack.com/services/url' }, pullmetry_access_token: access_token } @@ -126,7 +126,7 @@ context 'for valid custom params' do let(:request) { post :create, params: { - company_id: company.uuid, + company_id: company.id, webhook: { source: 'custom', url: 'https://hooks.slack.com/services/url' }, pullmetry_access_token: access_token } @@ -147,7 +147,7 @@ context 'for logged users' do let!(:webhook) { create :webhook, source: Webhook::SLACK } - let(:request) { delete :destroy, params: { id: webhook.uuid, pullmetry_access_token: access_token } } + let(:request) { delete :destroy, params: { id: webhook.id, pullmetry_access_token: access_token } } context 'for not user webhook' do it 'does not destroy webhook', :aggregate_failures do diff --git a/spec/controllers/frontend/work_times_controller_spec.rb b/spec/controllers/frontend/work_times_controller_spec.rb index 703fa46f..91926263 100644 --- a/spec/controllers/frontend/work_times_controller_spec.rb +++ b/spec/controllers/frontend/work_times_controller_spec.rb @@ -63,7 +63,7 @@ end context 'for existing company' do - let(:company_id) { company.uuid } + let(:company_id) { company.id } it 'does not create work time', :aggregate_failures do expect { request }.to change(WorkTime, :count).by(1) diff --git a/spec/controllers/web/companies/configurations_controller_spec.rb b/spec/controllers/web/companies/configurations_controller_spec.rb index 23b89fad..053f0670 100644 --- a/spec/controllers/web/companies/configurations_controller_spec.rb +++ b/spec/controllers/web/companies/configurations_controller_spec.rb @@ -26,7 +26,7 @@ context 'for not existing user company' do it 'renders access page' do - get :edit, params: { company_id: company.uuid, locale: 'en' } + get :edit, params: { company_id: company.id, locale: 'en' } expect(response).to render_template 'shared/access' end @@ -40,7 +40,7 @@ end it 'renders access page' do - get :edit, params: { company_id: company.uuid, locale: 'en' } + get :edit, params: { company_id: company.id, locale: 'en' } expect(response).to render_template 'shared/access' end @@ -50,7 +50,7 @@ before { company.update!(user: @current_user) } it 'renders new template' do - get :edit, params: { company_id: company.uuid, locale: 'en' } + get :edit, params: { company_id: company.id, locale: 'en' } expect(response).to render_template :edit end diff --git a/spec/controllers/web/companies/repositories_controller_spec.rb b/spec/controllers/web/companies/repositories_controller_spec.rb index 8a6f1165..5177fd40 100644 --- a/spec/controllers/web/companies/repositories_controller_spec.rb +++ b/spec/controllers/web/companies/repositories_controller_spec.rb @@ -25,7 +25,7 @@ end it 'renders index page' do - get :index, params: { company_id: company.uuid, locale: 'en' } + get :index, params: { company_id: company.id, locale: 'en' } expect(response).to render_template 'repositories/index' end @@ -36,7 +36,7 @@ context 'without repositories' do it 'renders index page' do - get :index, params: { company_id: company.uuid, locale: 'en' } + get :index, params: { company_id: company.id, locale: 'en' } expect(response).to render_template 'repositories/index' end @@ -49,7 +49,7 @@ end it 'renders index page' do - get :index, params: { company_id: company.uuid, locale: 'en' } + get :index, params: { company_id: company.id, locale: 'en' } expect(response).to render_template 'repositories/index' end diff --git a/spec/controllers/web/companies_controller_spec.rb b/spec/controllers/web/companies_controller_spec.rb index da94ba3b..6d858eca 100644 --- a/spec/controllers/web/companies_controller_spec.rb +++ b/spec/controllers/web/companies_controller_spec.rb @@ -52,14 +52,14 @@ def do_request context 'for not existing user company' do it 'renders 404 page' do - delete :destroy, params: { id: company.uuid, locale: 'en' } + delete :destroy, params: { id: company.id, locale: 'en' } expect(response).to render_template 'shared/404' end end context 'for existing user company' do - let(:request) { delete :destroy, params: { id: company.uuid, locale: 'en' } } + let(:request) { delete :destroy, params: { id: company.id, locale: 'en' } } before { company.update!(user: @current_user) } diff --git a/spec/controllers/web/repositories_controller_spec.rb b/spec/controllers/web/repositories_controller_spec.rb index c47a45ad..62bb73ab 100644 --- a/spec/controllers/web/repositories_controller_spec.rb +++ b/spec/controllers/web/repositories_controller_spec.rb @@ -54,14 +54,14 @@ def do_request context 'for not existing user company' do it 'renders 404 page' do - delete :destroy, params: { id: repository.uuid, locale: 'en' } + delete :destroy, params: { id: repository.id, locale: 'en' } expect(response).to render_template 'shared/404' end end context 'for existing user company' do - let(:request) { delete :destroy, params: { id: repository.uuid, locale: 'en' } } + let(:request) { delete :destroy, params: { id: repository.id, locale: 'en' } } before { repository.company.update!(user: @current_user) } diff --git a/spec/controllers/web/users/omniauth_callbacks_controller_spec.rb b/spec/controllers/web/users/omniauth_callbacks_controller_spec.rb index c614d7a5..6de1d1b3 100644 --- a/spec/controllers/web/users/omniauth_callbacks_controller_spec.rb +++ b/spec/controllers/web/users/omniauth_callbacks_controller_spec.rb @@ -121,12 +121,12 @@ end end - context 'with invite uuid in session' do + context 'with invite id in session' do let!(:invite) { create :invite } before do cookies[:pullmetry_invite_uuid] = { - value: invite.uuid, + value: invite.id, expires: 1.week.from_now } end diff --git a/spec/controllers/web/welcome_controller_spec.rb b/spec/controllers/web/welcome_controller_spec.rb index 096c2504..8168744c 100644 --- a/spec/controllers/web/welcome_controller_spec.rb +++ b/spec/controllers/web/welcome_controller_spec.rb @@ -26,7 +26,7 @@ get :index, params: { invite_code: invite.code, invite_email: invite.email } expect(response).to render_template :index - expect(cookies[:pullmetry_invite_uuid]).to eq invite.uuid + expect(cookies[:pullmetry_invite_uuid]).to eq invite.id end end end diff --git a/spec/controllers/webhooks/cryptoclouds_controller_spec.rb b/spec/controllers/webhooks/cryptoclouds_controller_spec.rb index 44607f1c..5b152bfe 100644 --- a/spec/controllers/webhooks/cryptoclouds_controller_spec.rb +++ b/spec/controllers/webhooks/cryptoclouds_controller_spec.rb @@ -29,7 +29,7 @@ context 'when user is found' do let!(:user) { create :user } - let(:order_id) { JwtEncoder.new.encode(payload: { uuid: user.uuid, days_period: 30 }) } + let(:order_id) { JwtEncoder.new.encode(payload: { uuid: user.id, days_period: 30 }) } context 'when order id is invalid' do let(:request) { post :create, params: { status: 'success', order_id: '123' } } @@ -75,7 +75,7 @@ before do allow(Pullmetry::Container.resolve('jwt_encoder')).to( - receive(:decode).with(token: order_id).and_return({ 'uuid' => user.uuid, 'days_period' => 30 }) + receive(:decode).with(token: order_id).and_return({ 'uuid' => user.id, 'days_period' => 30 }) ) allow(Pullmetry::Container.resolve('jwt_encoder')).to( diff --git a/spec/requests/api/v1/companies_spec.rb b/spec/requests/api/v1/companies_spec.rb index 645b19aa..9139db13 100644 --- a/spec/requests/api/v1/companies_spec.rb +++ b/spec/requests/api/v1/companies_spec.rb @@ -42,7 +42,7 @@ items: { type: :object, properties: { - uuid: { type: :string }, + id: { type: :string, format: :uuid }, title: { type: :string }, repositories_count: { type: :integer, nullable: true }, accessable: { type: :boolean } @@ -86,14 +86,14 @@ produces 'application/json' consumes 'application/json' - parameter name: :id, in: :path, type: :string, description: 'Company UUID', required: true + parameter name: :id, in: :path, type: :string, format: :uuid, description: 'Company ID', required: true parameter name: :api_access_token, in: :query, type: :string, description: 'API access token', required: true response(200, 'successful') do let(:user) { create :user } let(:api_access_token) { create(:api_access_token, user: user).value } let(:company) { create(:company, user: user) } - let(:id) { company.uuid } + let(:id) { company.id } let(:insight) { create :insight, insightable: company } after do |example| diff --git a/spec/requests/api/v1/repositories_spec.rb b/spec/requests/api/v1/repositories_spec.rb index 41da62fe..02339820 100644 --- a/spec/requests/api/v1/repositories_spec.rb +++ b/spec/requests/api/v1/repositories_spec.rb @@ -13,7 +13,7 @@ produces 'application/json' consumes 'application/json' - parameter name: :id, in: :path, type: :string, description: 'Repository UUID', required: true + parameter name: :id, in: :path, type: :string, format: :uuid, description: 'Repository ID', required: true parameter name: :api_access_token, in: :query, type: :string, description: 'API access token', required: true response(200, 'successful') do @@ -21,7 +21,7 @@ let(:api_access_token) { create(:api_access_token, user: user).value } let(:company) { create :company, user: user } let(:repository) { create :repository, company: company } - let(:id) { repository.uuid } + let(:id) { repository.id } let(:insight) { create :insight, insightable: repository } after do |example| diff --git a/spec/services/insights/time/for_review_spec.rb b/spec/services/insights/time/for_review_spec.rb index 6423b497..fed6d1b3 100644 --- a/spec/services/insights/time/for_review_spec.rb +++ b/spec/services/insights/time/for_review_spec.rb @@ -29,7 +29,8 @@ let(:insightable) { repository } it 'generates average time and succeeds', :aggregate_failures do - expect(service_call[:result]).to eq({ entity1.id => [43_200, 7_200], entity2.id => [3_600] }) + expect(service_call[:result][entity1.id]).to contain_exactly(7_200, 43_200) + expect(service_call[:result][entity2.id]).to contain_exactly(3_600) expect(service_call[:errors]).to be_blank end @@ -56,7 +57,8 @@ let(:insightable) { repository.company } it 'generates average time and succeeds', :aggregate_failures do - expect(service_call[:result]).to eq({ entity1.id => [43_200, 7_200], entity2.id => [3_600] }) + expect(service_call[:result][entity1.id]).to contain_exactly(7_200, 43_200) + expect(service_call[:result][entity2.id]).to contain_exactly(3_600) expect(service_call[:errors]).to be_blank end end @@ -68,7 +70,8 @@ let(:insightable) { repository } it 'generates average time and succeeds', :aggregate_failures do - expect(service_call[:result]).to eq({ entity1.id => [18_000, 7_200], entity2.id => [3_600] }) + expect(service_call[:result][entity1.id]).to contain_exactly(7_200, 18_000) + expect(service_call[:result][entity2.id]).to contain_exactly(3_600) expect(service_call[:errors]).to be_blank end end @@ -77,7 +80,8 @@ let(:insightable) { repository.company } it 'generates average time and succeeds', :aggregate_failures do - expect(service_call[:result]).to eq({ entity1.id => [18_000, 7_200], entity2.id => [3_600] }) + expect(service_call[:result][entity1.id]).to contain_exactly(7_200, 18_000) + expect(service_call[:result][entity2.id]).to contain_exactly(3_600) expect(service_call[:errors]).to be_blank end end @@ -89,7 +93,8 @@ let(:insightable) { repository } it 'generates average time and succeeds', :aggregate_failures do - expect(service_call[:result]).to eq({ entity1.id => [50_400, 7_200], entity2.id => [3_600] }) + expect(service_call[:result][entity1.id]).to contain_exactly(7_200, 50_400) + expect(service_call[:result][entity2.id]).to contain_exactly(3_600) expect(service_call[:errors]).to be_blank end end @@ -98,7 +103,8 @@ let(:insightable) { repository.company } it 'generates average time and succeeds', :aggregate_failures do - expect(service_call[:result]).to eq({ entity1.id => [50_400, 7_200], entity2.id => [3_600] }) + expect(service_call[:result][entity1.id]).to contain_exactly(7_200, 50_400) + expect(service_call[:result][entity2.id]).to contain_exactly(3_600) expect(service_call[:errors]).to be_blank end end @@ -110,7 +116,8 @@ let(:insightable) { repository } it 'generates average time and succeeds', :aggregate_failures do - expect(service_call[:result]).to eq({ entity1.id => [50_400, 7_200], entity2.id => [14_400] }) + expect(service_call[:result][entity1.id]).to contain_exactly(7_200, 50_400) + expect(service_call[:result][entity2.id]).to contain_exactly(14_400) expect(service_call[:errors]).to be_blank end end @@ -119,7 +126,8 @@ let(:insightable) { repository.company } it 'generates average time and succeeds', :aggregate_failures do - expect(service_call[:result]).to eq({ entity1.id => [50_400, 7_200], entity2.id => [14_400] }) + expect(service_call[:result][entity1.id]).to contain_exactly(7_200, 50_400) + expect(service_call[:result][entity2.id]).to contain_exactly(14_400) expect(service_call[:errors]).to be_blank end end @@ -132,7 +140,8 @@ let(:insightable) { repository } it 'generates average time and succeeds', :aggregate_failures do - expect(service_call[:result]).to eq({ entity1.id => [50_400, 7_200], entity2.id => [32_400] }) + expect(service_call[:result][entity1.id]).to contain_exactly(7_200, 50_400) + expect(service_call[:result][entity2.id]).to contain_exactly(32_400) expect(service_call[:errors]).to be_blank end end @@ -141,7 +150,8 @@ let(:insightable) { repository.company } it 'generates average time and succeeds', :aggregate_failures do - expect(service_call[:result]).to eq({ entity1.id => [50_400, 7_200], entity2.id => [32_400] }) + expect(service_call[:result][entity1.id]).to contain_exactly(7_200, 50_400) + expect(service_call[:result][entity2.id]).to contain_exactly(32_400) expect(service_call[:errors]).to be_blank end end @@ -157,7 +167,8 @@ let(:insightable) { repository } it 'generates average time and succeeds', :aggregate_failures do - expect(service_call[:result]).to eq({ entity1.id => [50_400, 7_200], entity2.id => [0] }) + expect(service_call[:result][entity1.id]).to contain_exactly(7_200, 50_400) + expect(service_call[:result][entity2.id]).to contain_exactly(0) expect(service_call[:errors]).to be_blank end end @@ -166,7 +177,8 @@ let(:insightable) { repository.company } it 'generates average time and succeeds', :aggregate_failures do - expect(service_call[:result]).to eq({ entity1.id => [50_400, 7_200], entity2.id => [0] }) + expect(service_call[:result][entity1.id]).to contain_exactly(7_200, 50_400) + expect(service_call[:result][entity2.id]).to contain_exactly(0) expect(service_call[:errors]).to be_blank end end diff --git a/swagger/v1/swagger.yaml b/swagger/v1/swagger.yaml index 6dea55a1..9088450e 100644 --- a/swagger/v1/swagger.yaml +++ b/swagger/v1/swagger.yaml @@ -44,8 +44,9 @@ paths: items: type: object properties: - uuid: + id: type: string + format: uuid title: type: string repositories_count: @@ -73,7 +74,8 @@ paths: parameters: - name: id in: path - description: Company UUID + format: uuid + description: Company ID required: true schema: type: string @@ -130,7 +132,8 @@ paths: parameters: - name: id in: path - description: Repository UUID + format: uuid + description: Repository ID required: true schema: type: string From 480493fe33ebdc1cbaad8cee72826e2f9d1fd904 Mon Sep 17 00:00:00 2001 From: Bogdanov Anton Date: Sun, 16 Mar 2025 12:12:43 +0300 Subject: [PATCH 2/2] prepare release --- Gemfile.lock | 2 +- .../stylesheets/application.tailwind.css | 4 ++++ .../admin/companies/repositories_controller.rb | 2 +- app/controllers/admin/companies_controller.rb | 2 +- .../admin/configurations_controller.rb | 2 +- app/controllers/admin/feedbacks_controller.rb | 2 +- .../admin/notifications_controller.rb | 2 +- .../admin/repositories_controller.rb | 2 +- .../admin/subscribers_controller.rb | 2 +- app/controllers/admin/users_controller.rb | 2 +- app/controllers/admin/webhooks_controller.rb | 2 +- app/controllers/api/v1/companies_controller.rb | 2 +- app/controllers/api/v1/insights_controller.rb | 4 ++-- .../frontend/insights_controller.rb | 4 ++-- .../repository_insights_controller.rb | 2 +- .../web/companies/configurations_controller.rb | 2 +- .../web/companies/repositories_controller.rb | 2 +- app/controllers/web/companies_controller.rb | 2 +- app/controllers/web/repositories_controller.rb | 2 +- .../page_wrappers/admin_component.html.erb | 18 +++++++++--------- db/migrate/20241207182227_backfill_data.rb | 11 ++++++++++- db/structure.sql | 1 + 22 files changed, 44 insertions(+), 30 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0666316c..68a3b587 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -480,7 +480,7 @@ GEM concurrent-ruby (~> 1.0) unicode-display_width (2.6.0) uniform_notifier (1.16.0) - uri (1.0.2) + uri (1.0.3) useragent (0.16.11) view_component (3.20.0) activesupport (>= 5.2.0, < 8.1) diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css index 5cf8b486..d04eae82 100644 --- a/app/assets/stylesheets/application.tailwind.css +++ b/app/assets/stylesheets/application.tailwind.css @@ -225,6 +225,10 @@ nav.pagy.nav a.gap { @apply relative inline-block text-white leading-6 whitespace-nowrap flex flex-row items-center mb-4 p-2.5 pl-3; } +.user-navigation-link.admin { + @apply text-black; +} + .user-navigation-link span:nth-of-type(1) { @apply w-6 flex justify-center; } diff --git a/app/controllers/admin/companies/repositories_controller.rb b/app/controllers/admin/companies/repositories_controller.rb index 4bb7d007..f6779135 100644 --- a/app/controllers/admin/companies/repositories_controller.rb +++ b/app/controllers/admin/companies/repositories_controller.rb @@ -23,7 +23,7 @@ def find_company def find_repositories @pagy, @repositories = pagy( - @company.repositories.order(id: :desc).includes(:access_token), + @company.repositories.order(created_at: :desc).includes(:access_token), limit: PER_PAGE ) end diff --git a/app/controllers/admin/companies_controller.rb b/app/controllers/admin/companies_controller.rb index d1c6e6cc..958aa968 100644 --- a/app/controllers/admin/companies_controller.rb +++ b/app/controllers/admin/companies_controller.rb @@ -13,7 +13,7 @@ def index; end private def find_companies - @pagy, @companies = pagy(Company.includes(:access_token).order(id: :desc), limit: PER_PAGE) + @pagy, @companies = pagy(Company.includes(:access_token).order(created_at: :desc), limit: PER_PAGE) end end end diff --git a/app/controllers/admin/configurations_controller.rb b/app/controllers/admin/configurations_controller.rb index 00394b49..df68c6e6 100644 --- a/app/controllers/admin/configurations_controller.rb +++ b/app/controllers/admin/configurations_controller.rb @@ -13,7 +13,7 @@ def index; end private def find_companies - @pagy, @companies = pagy(Company.includes(:user).order(id: :desc), limit: PER_PAGE) + @pagy, @companies = pagy(Company.includes(:user).order(created_at: :desc), limit: PER_PAGE) end end end diff --git a/app/controllers/admin/feedbacks_controller.rb b/app/controllers/admin/feedbacks_controller.rb index 658a80aa..fdcca565 100644 --- a/app/controllers/admin/feedbacks_controller.rb +++ b/app/controllers/admin/feedbacks_controller.rb @@ -13,7 +13,7 @@ def index; end private def find_feedbacks - @pagy, @feedbacks = pagy(User::Feedback.order(id: :desc), limit: PER_PAGE) + @pagy, @feedbacks = pagy(User::Feedback.order(created_at: :desc), limit: PER_PAGE) end end end diff --git a/app/controllers/admin/notifications_controller.rb b/app/controllers/admin/notifications_controller.rb index 2719277f..97a83c18 100644 --- a/app/controllers/admin/notifications_controller.rb +++ b/app/controllers/admin/notifications_controller.rb @@ -13,7 +13,7 @@ def index; end private def find_notifications - @pagy, @notifications = pagy(Notification.order(id: :desc), limit: PER_PAGE) + @pagy, @notifications = pagy(Notification.order(created_at: :desc), limit: PER_PAGE) end end end diff --git a/app/controllers/admin/repositories_controller.rb b/app/controllers/admin/repositories_controller.rb index 8df162d6..b235726a 100644 --- a/app/controllers/admin/repositories_controller.rb +++ b/app/controllers/admin/repositories_controller.rb @@ -21,7 +21,7 @@ def destroy def find_repositories @pagy, @repositories = pagy( - Repository.order(id: :desc).includes(:access_token, company: %i[access_token]), + Repository.order(created_at: :desc).includes(:access_token, company: %i[access_token]), limit: PER_PAGE ) end diff --git a/app/controllers/admin/subscribers_controller.rb b/app/controllers/admin/subscribers_controller.rb index 7edb96d7..8def7597 100644 --- a/app/controllers/admin/subscribers_controller.rb +++ b/app/controllers/admin/subscribers_controller.rb @@ -13,7 +13,7 @@ def index; end private def find_subscribers - @pagy, @subscribers = pagy(Subscriber.order(id: :desc), limit: PER_PAGE) + @pagy, @subscribers = pagy(Subscriber.order(created_at: :desc), limit: PER_PAGE) end end end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 1849e8b4..7528a910 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -13,7 +13,7 @@ def index; end private def find_users - @pagy, @users = pagy(User.order(id: :desc), limit: PER_PAGE) + @pagy, @users = pagy(User.order(created_at: :desc), limit: PER_PAGE) end end end diff --git a/app/controllers/admin/webhooks_controller.rb b/app/controllers/admin/webhooks_controller.rb index 695fe2b1..6cf0f0c8 100644 --- a/app/controllers/admin/webhooks_controller.rb +++ b/app/controllers/admin/webhooks_controller.rb @@ -13,7 +13,7 @@ def index; end private def find_webhooks - @pagy, @webhooks = pagy(Webhook.order(id: :desc), limit: PER_PAGE) + @pagy, @webhooks = pagy(Webhook.order(created_at: :desc), limit: PER_PAGE) end end end diff --git a/app/controllers/api/v1/companies_controller.rb b/app/controllers/api/v1/companies_controller.rb index 9e3b5b30..d803e085 100644 --- a/app/controllers/api/v1/companies_controller.rb +++ b/app/controllers/api/v1/companies_controller.rb @@ -18,7 +18,7 @@ def index private def companies - current_user.available_companies.order(id: :desc) + current_user.available_companies.order(created_at: :desc) end end end diff --git a/app/controllers/api/v1/insights_controller.rb b/app/controllers/api/v1/insights_controller.rb index 28aad746..1e8ae250 100644 --- a/app/controllers/api/v1/insights_controller.rb +++ b/app/controllers/api/v1/insights_controller.rb @@ -36,11 +36,11 @@ def find_insightable end def find_company - @insightable = authorized_scope(Company.order(id: :desc)).find_by(id: params[:company_id]) + @insightable = authorized_scope(Company.order(created_at: :desc)).find_by(id: params[:company_id]) end def find_repository - @insightable = authorized_scope(Repository.order(id: :desc)).find_by(id: params[:repository_id]) + @insightable = authorized_scope(Repository.order(created_at: :desc)).find_by(id: params[:repository_id]) end def visible_insights diff --git a/app/controllers/frontend/insights_controller.rb b/app/controllers/frontend/insights_controller.rb index 696656fb..3ed0c584 100644 --- a/app/controllers/frontend/insights_controller.rb +++ b/app/controllers/frontend/insights_controller.rb @@ -54,11 +54,11 @@ def find_insightable end def find_company - @insightable = authorized_scope(Company.order(id: :desc)).find_by(id: params[:company_id]) + @insightable = authorized_scope(Company.order(created_at: :desc)).find_by(id: params[:company_id]) end def find_repository - @insightable = authorized_scope(Repository.order(id: :desc)).find_by(id: params[:repository_id]) + @insightable = authorized_scope(Repository.order(created_at: :desc)).find_by(id: params[:repository_id]) end def visible_insights diff --git a/app/controllers/frontend/repositories/repository_insights_controller.rb b/app/controllers/frontend/repositories/repository_insights_controller.rb index 1b24322d..007add11 100644 --- a/app/controllers/frontend/repositories/repository_insights_controller.rb +++ b/app/controllers/frontend/repositories/repository_insights_controller.rb @@ -33,7 +33,7 @@ def json_response(response) end def find_repository - @repository = authorized_scope(Repository.order(id: :desc)).find(params[:repository_id]) + @repository = authorized_scope(Repository.order(created_at: :desc)).find(params[:repository_id]) end def visible_insights diff --git a/app/controllers/web/companies/configurations_controller.rb b/app/controllers/web/companies/configurations_controller.rb index db5a3961..1a01e174 100644 --- a/app/controllers/web/companies/configurations_controller.rb +++ b/app/controllers/web/companies/configurations_controller.rb @@ -43,7 +43,7 @@ def find_excludes_groups @excludes_groups = JSON.parse( Panko::ArraySerializer.new( - @company.excludes_groups.order(id: :desc), + @company.excludes_groups.order(created_at: :desc), each_serializer: Excludes::GroupSerializer, context: { rules: excludes_rules diff --git a/app/controllers/web/companies/repositories_controller.rb b/app/controllers/web/companies/repositories_controller.rb index 83f8ad72..2005fc18 100644 --- a/app/controllers/web/companies/repositories_controller.rb +++ b/app/controllers/web/companies/repositories_controller.rb @@ -25,7 +25,7 @@ def find_repositories @pagy, @repositories = pagy( authorized_scope( - @company.repositories.order(id: :desc) + @company.repositories.order(created_at: :desc) ).includes(:access_token), limit: PER_PAGE ) diff --git a/app/controllers/web/companies_controller.rb b/app/controllers/web/companies_controller.rb index 04be3aff..4ef97edc 100644 --- a/app/controllers/web/companies_controller.rb +++ b/app/controllers/web/companies_controller.rb @@ -22,7 +22,7 @@ def destroy def find_companies @pagy, @companies = - pagy(authorized_scope(Company.order(id: :desc).includes(:user)), limit: PER_PAGE) + pagy(authorized_scope(Company.order(created_at: :desc).includes(:user)), limit: PER_PAGE) end def find_accounts_for_companies diff --git a/app/controllers/web/repositories_controller.rb b/app/controllers/web/repositories_controller.rb index 8e888c7d..66b10f53 100644 --- a/app/controllers/web/repositories_controller.rb +++ b/app/controllers/web/repositories_controller.rb @@ -24,7 +24,7 @@ def find_repositories @pagy, @repositories = pagy( authorized_scope( - Repository.order(id: :desc) + Repository.order(created_at: :desc) ).includes(:access_token, company: %i[access_token user]), limit: PER_PAGE ) diff --git a/app/views/components/page_wrappers/admin_component.html.erb b/app/views/components/page_wrappers/admin_component.html.erb index abd32647..37e79b08 100644 --- a/app/views/components/page_wrappers/admin_component.html.erb +++ b/app/views/components/page_wrappers/admin_component.html.erb @@ -1,32 +1,32 @@
- <%= link_to root_path, class: 'user-navigation-link lg:my-4 text-xl' do %> + <%= link_to root_path, class: 'user-navigation-link admin lg:my-4 text-xl' do %> PullKeeper <% end %>
- <%= link_to 'Companies', admin_companies_path, class: 'user-navigation-link' %> + <%= link_to 'Companies', admin_companies_path, class: 'user-navigation-link admin' %>
- <%= link_to 'Configurations', admin_configurations_path, class: 'user-navigation-link' %> + <%= link_to 'Configurations', admin_configurations_path, class: 'user-navigation-link admin' %>
- <%= link_to 'Repositories', admin_repositories_path, class: 'user-navigation-link' %> + <%= link_to 'Repositories', admin_repositories_path, class: 'user-navigation-link admin' %>
- <%= link_to 'Notifications', admin_notifications_path, class: 'user-navigation-link' %> + <%= link_to 'Notifications', admin_notifications_path, class: 'user-navigation-link admin' %>
- <%= link_to 'Webhooks', admin_webhooks_path, class: 'user-navigation-link' %> + <%= link_to 'Webhooks', admin_webhooks_path, class: 'user-navigation-link admin' %>
- <%= link_to 'Users', admin_users_path, class: 'user-navigation-link' %> + <%= link_to 'Users', admin_users_path, class: 'user-navigation-link admin' %>
- <%= link_to 'Feedbacks', admin_feedbacks_path, class: 'user-navigation-link' %> + <%= link_to 'Feedbacks', admin_feedbacks_path, class: 'user-navigation-link admin' %>
- <%= link_to 'Subscribers', admin_subscribers_path, class: 'user-navigation-link' %> + <%= link_to 'Subscribers', admin_subscribers_path, class: 'user-navigation-link admin' %>
diff --git a/db/migrate/20241207182227_backfill_data.rb b/db/migrate/20241207182227_backfill_data.rb index 5c2c6d06..1f83d59c 100644 --- a/db/migrate/20241207182227_backfill_data.rb +++ b/db/migrate/20241207182227_backfill_data.rb @@ -77,8 +77,11 @@ def up end Insight.find_each do |item| + insightable = item.insightable_type.constantize.find_by(numeric_id: item.numeric_insightable_id) + next if insightable.nil? + item.update!( - insightable_id: item.insightable_type.constantize.find_by(numeric_id: item.numeric_insightable_id).id, + insightable_id: insightable.id, entity_id: Entity.find_by(numeric_id: item.numeric_entity_id).id ) end @@ -136,6 +139,8 @@ def up item.update!(user_id: User.find_by(numeric_id: item.numeric_user_id).id) end + Insight.where(insightable_id: nil).destroy_all + safety_assured do change_column_null :vacations, :user_id, false change_column_null :users_sessions, :user_id, false @@ -203,6 +208,10 @@ def up change_column_null :pull_requests_reviews, :numeric_entity_id, true change_column_null :kudos_users_achievements, :numeric_user_id, true end + + Company.find_each do |company| + Company.reset_counters company.id, :repositories_count + end end def down; end diff --git a/db/structure.sql b/db/structure.sql index 842c6151..83abfee3 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1,6 +1,7 @@ SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; +SET transaction_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false);