Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-16 18:09:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-16 18:09:50 +0300
commitb4e854a900ba9bcbfc3476f88317c59ea048daaf (patch)
tree562b380f7d3587c522d57487465b8df9d0c34746 /db
parent8215fc964a189ae5c876a10f2e7d61933a725e24 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20210128152830_create_ci_namespace_monthly_usage.rb30
-rw-r--r--db/migrate/20210205084357_create_ci_project_monthly_usage.rb29
-rw-r--r--db/post_migrate/20210210093901_backfill_updated_at_after_repository_storage_move.rb34
-rw-r--r--db/schema_migrations/202101281528301
-rw-r--r--db/schema_migrations/202102050843571
-rw-r--r--db/schema_migrations/202102100939011
-rw-r--r--db/structure.sql52
7 files changed, 148 insertions, 0 deletions
diff --git a/db/migrate/20210128152830_create_ci_namespace_monthly_usage.rb b/db/migrate/20210128152830_create_ci_namespace_monthly_usage.rb
new file mode 100644
index 00000000000..d6ee057a56b
--- /dev/null
+++ b/db/migrate/20210128152830_create_ci_namespace_monthly_usage.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class CreateCiNamespaceMonthlyUsage < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ create_table :ci_namespace_monthly_usages, if_not_exists: true do |t|
+ t.references :namespace, index: false, null: false
+ t.date :date, null: false
+ t.integer :additional_amount_available, null: false, default: 0
+ t.decimal :amount_used, null: false, default: 0.0, precision: 18, scale: 2
+
+ t.index [:namespace_id, :date], unique: true
+ end
+ end
+
+ add_check_constraint :ci_namespace_monthly_usages, "(date = date_trunc('month', date))", 'ci_namespace_monthly_usages_year_month_constraint'
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :ci_namespace_monthly_usages
+ end
+ end
+end
diff --git a/db/migrate/20210205084357_create_ci_project_monthly_usage.rb b/db/migrate/20210205084357_create_ci_project_monthly_usage.rb
new file mode 100644
index 00000000000..c91bfa5ee1c
--- /dev/null
+++ b/db/migrate/20210205084357_create_ci_project_monthly_usage.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class CreateCiProjectMonthlyUsage < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ create_table :ci_project_monthly_usages, if_not_exists: true do |t|
+ t.references :project, foreign_key: { on_delete: :cascade }, index: false, null: false
+ t.date :date, null: false
+ t.decimal :amount_used, null: false, default: 0.0, precision: 18, scale: 2
+
+ t.index [:project_id, :date], unique: true
+ end
+ end
+
+ add_check_constraint :ci_project_monthly_usages, "(date = date_trunc('month', date))", 'ci_project_monthly_usages_year_month_constraint'
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :ci_project_monthly_usages
+ end
+ end
+end
diff --git a/db/post_migrate/20210210093901_backfill_updated_at_after_repository_storage_move.rb b/db/post_migrate/20210210093901_backfill_updated_at_after_repository_storage_move.rb
new file mode 100644
index 00000000000..0631cc8095e
--- /dev/null
+++ b/db/post_migrate/20210210093901_backfill_updated_at_after_repository_storage_move.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class BackfillUpdatedAtAfterRepositoryStorageMove < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ BATCH_SIZE = 10_000
+ INTERVAL = 2.minutes
+ MIGRATION_CLASS = 'BackfillProjectUpdatedAtAfterRepositoryStorageMove'
+
+ disable_ddl_transaction!
+
+ class ProjectRepositoryStorageMove < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'project_repository_storage_moves'
+ end
+
+ def up
+ ProjectRepositoryStorageMove.reset_column_information
+
+ ProjectRepositoryStorageMove.select(:project_id).distinct.each_batch(of: BATCH_SIZE, column: :project_id) do |batch, index|
+ migrate_in(
+ INTERVAL * index,
+ MIGRATION_CLASS,
+ batch.pluck(:project_id)
+ )
+ end
+ end
+
+ def down
+ # No-op
+ end
+end
diff --git a/db/schema_migrations/20210128152830 b/db/schema_migrations/20210128152830
new file mode 100644
index 00000000000..36d3de788eb
--- /dev/null
+++ b/db/schema_migrations/20210128152830
@@ -0,0 +1 @@
+932509d18f1cfdfa09f1565e4ac2f197b7ca792263ff5da3e5b712fae7279925 \ No newline at end of file
diff --git a/db/schema_migrations/20210205084357 b/db/schema_migrations/20210205084357
new file mode 100644
index 00000000000..6babb782c70
--- /dev/null
+++ b/db/schema_migrations/20210205084357
@@ -0,0 +1 @@
+5bd622f36126b06c7c585ee14a8140750843d36092e79b6cc35b62c06afb1178 \ No newline at end of file
diff --git a/db/schema_migrations/20210210093901 b/db/schema_migrations/20210210093901
new file mode 100644
index 00000000000..c1bbb93de21
--- /dev/null
+++ b/db/schema_migrations/20210210093901
@@ -0,0 +1 @@
+961c147e9c8e35eac5b8dd33f879582e173b7f6e31659b2d00989bc38afc6f5a \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 386fbe4ee3f..045b3000998 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -10506,6 +10506,24 @@ CREATE SEQUENCE ci_job_variables_id_seq
ALTER SEQUENCE ci_job_variables_id_seq OWNED BY ci_job_variables.id;
+CREATE TABLE ci_namespace_monthly_usages (
+ id bigint NOT NULL,
+ namespace_id bigint NOT NULL,
+ date date NOT NULL,
+ additional_amount_available integer DEFAULT 0 NOT NULL,
+ amount_used numeric(18,2) DEFAULT 0.0 NOT NULL,
+ CONSTRAINT ci_namespace_monthly_usages_year_month_constraint CHECK ((date = date_trunc('month'::text, (date)::timestamp with time zone)))
+);
+
+CREATE SEQUENCE ci_namespace_monthly_usages_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE ci_namespace_monthly_usages_id_seq OWNED BY ci_namespace_monthly_usages.id;
+
CREATE TABLE ci_pipeline_artifacts (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -10703,6 +10721,23 @@ CREATE SEQUENCE ci_platform_metrics_id_seq
ALTER SEQUENCE ci_platform_metrics_id_seq OWNED BY ci_platform_metrics.id;
+CREATE TABLE ci_project_monthly_usages (
+ id bigint NOT NULL,
+ project_id bigint NOT NULL,
+ date date NOT NULL,
+ amount_used numeric(18,2) DEFAULT 0.0 NOT NULL,
+ CONSTRAINT ci_project_monthly_usages_year_month_constraint CHECK ((date = date_trunc('month'::text, (date)::timestamp with time zone)))
+);
+
+CREATE SEQUENCE ci_project_monthly_usages_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE ci_project_monthly_usages_id_seq OWNED BY ci_project_monthly_usages.id;
+
CREATE TABLE ci_refs (
id bigint NOT NULL,
project_id bigint NOT NULL,
@@ -18747,6 +18782,8 @@ ALTER TABLE ONLY ci_job_artifacts ALTER COLUMN id SET DEFAULT nextval('ci_job_ar
ALTER TABLE ONLY ci_job_variables ALTER COLUMN id SET DEFAULT nextval('ci_job_variables_id_seq'::regclass);
+ALTER TABLE ONLY ci_namespace_monthly_usages ALTER COLUMN id SET DEFAULT nextval('ci_namespace_monthly_usages_id_seq'::regclass);
+
ALTER TABLE ONLY ci_pipeline_artifacts ALTER COLUMN id SET DEFAULT nextval('ci_pipeline_artifacts_id_seq'::regclass);
ALTER TABLE ONLY ci_pipeline_chat_data ALTER COLUMN id SET DEFAULT nextval('ci_pipeline_chat_data_id_seq'::regclass);
@@ -18765,6 +18802,8 @@ ALTER TABLE ONLY ci_pipelines_config ALTER COLUMN pipeline_id SET DEFAULT nextva
ALTER TABLE ONLY ci_platform_metrics ALTER COLUMN id SET DEFAULT nextval('ci_platform_metrics_id_seq'::regclass);
+ALTER TABLE ONLY ci_project_monthly_usages ALTER COLUMN id SET DEFAULT nextval('ci_project_monthly_usages_id_seq'::regclass);
+
ALTER TABLE ONLY ci_refs ALTER COLUMN id SET DEFAULT nextval('ci_refs_id_seq'::regclass);
ALTER TABLE ONLY ci_resource_groups ALTER COLUMN id SET DEFAULT nextval('ci_resource_groups_id_seq'::regclass);
@@ -19860,6 +19899,9 @@ ALTER TABLE ONLY ci_job_artifacts
ALTER TABLE ONLY ci_job_variables
ADD CONSTRAINT ci_job_variables_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY ci_namespace_monthly_usages
+ ADD CONSTRAINT ci_namespace_monthly_usages_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY ci_pipeline_artifacts
ADD CONSTRAINT ci_pipeline_artifacts_pkey PRIMARY KEY (id);
@@ -19887,6 +19929,9 @@ ALTER TABLE ONLY ci_pipelines
ALTER TABLE ONLY ci_platform_metrics
ADD CONSTRAINT ci_platform_metrics_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY ci_project_monthly_usages
+ ADD CONSTRAINT ci_project_monthly_usages_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY ci_refs
ADD CONSTRAINT ci_refs_pkey PRIMARY KEY (id);
@@ -21658,6 +21703,8 @@ CREATE INDEX index_ci_job_variables_on_job_id ON ci_job_variables USING btree (j
CREATE UNIQUE INDEX index_ci_job_variables_on_key_and_job_id ON ci_job_variables USING btree (key, job_id);
+CREATE UNIQUE INDEX index_ci_namespace_monthly_usages_on_namespace_id_and_date ON ci_namespace_monthly_usages USING btree (namespace_id, date);
+
CREATE INDEX index_ci_pipeline_artifacts_on_expire_at ON ci_pipeline_artifacts USING btree (expire_at);
CREATE INDEX index_ci_pipeline_artifacts_on_pipeline_id ON ci_pipeline_artifacts USING btree (pipeline_id);
@@ -21722,6 +21769,8 @@ CREATE INDEX index_ci_pipelines_on_user_id_and_created_at_and_config_source ON c
CREATE INDEX index_ci_pipelines_on_user_id_and_created_at_and_source ON ci_pipelines USING btree (user_id, created_at, source);
+CREATE UNIQUE INDEX index_ci_project_monthly_usages_on_project_id_and_date ON ci_project_monthly_usages USING btree (project_id, date);
+
CREATE UNIQUE INDEX index_ci_refs_on_project_id_and_ref_path ON ci_refs USING btree (project_id, ref_path);
CREATE UNIQUE INDEX index_ci_resource_groups_on_project_id_and_key ON ci_resource_groups USING btree (project_id, key);
@@ -25241,6 +25290,9 @@ ALTER TABLE ONLY resource_iteration_events
ALTER TABLE ONLY status_page_settings
ADD CONSTRAINT fk_rails_506e5ba391 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY ci_project_monthly_usages
+ ADD CONSTRAINT fk_rails_508bcd4aa6 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY project_repository_storage_moves
ADD CONSTRAINT fk_rails_5106dbd44a FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;