debian-mirror-gitlab/app/models/terraform/state_version.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
890 B
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
module Terraform
class StateVersion < ApplicationRecord
2022-07-23 23:45:48 +05:30
include EachBatch
2020-11-24 15:15:51 +05:30
include FileStoreMounter
2023-06-20 00:43:36 +05:30
belongs_to :terraform_state, class_name: 'Terraform::State', optional: false, touch: true
2020-11-24 15:15:51 +05:30
belongs_to :created_by_user, class_name: 'User', optional: true
2021-01-29 00:20:46 +05:30
belongs_to :build, class_name: 'Ci::Build', optional: true, foreign_key: :ci_build_id
2020-11-24 15:15:51 +05:30
scope :ordered_by_version_desc, -> { order(version: :desc) }
2021-03-11 19:13:27 +05:30
scope :with_files_stored_locally, -> { where(file_store: Terraform::StateUploader::Store::LOCAL) }
scope :preload_state, -> { includes(:terraform_state) }
2020-11-24 15:15:51 +05:30
2023-01-13 00:05:48 +05:30
attribute :file_store, default: -> { StateUploader.default_store }
2020-11-24 15:15:51 +05:30
2021-02-22 17:27:13 +05:30
mount_file_store_uploader StateUploader
2020-11-24 15:15:51 +05:30
delegate :project_id, :uuid, to: :terraform_state, allow_nil: true
end
end
2021-01-03 14:25:43 +05:30
2021-06-08 01:23:25 +05:30
Terraform::StateVersion.prepend_mod_with('Terraform::StateVersion')