travis-backup-for-v3 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile.lock +1 -1
  4. data/README.md +3 -1
  5. data/db/schema.sql +0 -2
  6. data/lib/backup/remove_specified/remove_heavy_data.rb +103 -17
  7. data/lib/backup/save_id_hash_to_file.rb +0 -1
  8. data/lib/backup/save_nullified_rels_to_file.rb +2 -2
  9. data/lib/config.rb +7 -12
  10. data/lib/db_helper.rb +5 -1
  11. data/lib/models/abuse.rb +2 -0
  12. data/lib/models/beta_migration_request.rb +2 -0
  13. data/lib/models/branch.rb +2 -0
  14. data/lib/models/broadcast.rb +2 -0
  15. data/lib/models/build.rb +2 -0
  16. data/lib/models/build_config.rb +2 -0
  17. data/lib/models/cancellation.rb +2 -0
  18. data/lib/models/commit.rb +2 -0
  19. data/lib/models/cron.rb +2 -0
  20. data/lib/models/deleted_build.rb +2 -9
  21. data/lib/models/deleted_build_config.rb +2 -2
  22. data/lib/models/deleted_commit.rb +2 -6
  23. data/lib/models/deleted_job.rb +2 -2
  24. data/lib/models/deleted_job_config.rb +2 -2
  25. data/lib/models/deleted_pull_request.rb +2 -4
  26. data/lib/models/deleted_request.rb +2 -10
  27. data/lib/models/deleted_request_config.rb +2 -2
  28. data/lib/models/deleted_request_payload.rb +2 -0
  29. data/lib/models/deleted_request_raw_config.rb +2 -2
  30. data/lib/models/deleted_request_raw_configuration.rb +2 -0
  31. data/lib/models/deleted_request_yaml_config.rb +2 -2
  32. data/lib/models/deleted_ssl_key.rb +2 -0
  33. data/lib/models/deleted_stage.rb +2 -2
  34. data/lib/models/deleted_tag.rb +2 -6
  35. data/lib/models/email.rb +2 -0
  36. data/lib/models/email_unsubscribe.rb +2 -0
  37. data/lib/models/installation.rb +2 -0
  38. data/lib/models/invoice.rb +2 -0
  39. data/lib/models/job_config.rb +2 -0
  40. data/lib/models/job_version.rb +2 -0
  41. data/lib/models/membership.rb +2 -0
  42. data/lib/models/message.rb +2 -0
  43. data/lib/models/organization.rb +2 -0
  44. data/lib/models/owner_group.rb +2 -0
  45. data/lib/models/permission.rb +2 -0
  46. data/lib/models/pull_request.rb +2 -0
  47. data/lib/models/queueable_job.rb +2 -0
  48. data/lib/models/repo_count.rb +2 -0
  49. data/lib/models/repository.rb +2 -0
  50. data/lib/models/request.rb +2 -0
  51. data/lib/models/request_config.rb +2 -0
  52. data/lib/models/request_payload.rb +2 -0
  53. data/lib/models/request_raw_config.rb +2 -0
  54. data/lib/models/request_raw_configuration.rb +2 -0
  55. data/lib/models/request_yaml_config.rb +2 -0
  56. data/lib/models/ssl_key.rb +2 -0
  57. data/lib/models/stage.rb +2 -0
  58. data/lib/models/star.rb +2 -0
  59. data/lib/models/subscription.rb +2 -0
  60. data/lib/models/tag.rb +2 -0
  61. data/lib/models/token.rb +2 -0
  62. data/lib/models/trial.rb +2 -0
  63. data/lib/models/trial_allowance.rb +2 -0
  64. data/lib/models/user.rb +2 -0
  65. data/lib/models/user_beta_feature.rb +2 -0
  66. data/lib/models/user_utm_param.rb +2 -0
  67. data/travis-backup-for-v3.gemspec +1 -1
  68. metadata +2 -3
  69. data/workspace.code-workspace +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3fe0e536c1a109fb799ac8f5f66f1682733fc2e23a3a6f41139db81b4e56994
4
- data.tar.gz: 6179311474e9df23ab9f04936621f917803af5f5d584c36545bc4fe1cd6a394c
3
+ metadata.gz: 416a6dc6ebe2ab1b8cfae65a8a672b73170aef4506de1da5abd40f0960319d07
4
+ data.tar.gz: 011cfada8099c49c95c45fa8b80e1aa110959fea4e5d92db787f0d5e26c801d6
5
5
  SHA512:
6
- metadata.gz: 1584e4ad9062f6827fe76f352b1d1042b4cf36bc16f5f67edb751a6d72efea1dbd802cf824ca05ad5fbebd8dd40eecd1662495602ed4acb2829b12473e092f1c
7
- data.tar.gz: d3b475c84985217a86564597169093c39e85f782b0316c0f9631881e561d69216a829c364a7e19892626fd8295338d354e16f353e30036eb18f818fc83e12c54
6
+ metadata.gz: d8fff5c1c4f8e03fdbf594fb89330cd8f4b1129b69cbede0c843ea8dfe294907f85eab346254b36468aa4e3f7dbbd687ae17d1de0a47e2024f99a1ed42f1244c
7
+ data.tar.gz: e75938ae7fd17a8779fa73d976d6712135ae5e1f39b08e056c791c302f0bd0ba555a70c690c96af0580caaacabf8f4f9f1f22b33a518492f396b93a54162c9a9
data/.gitignore CHANGED
@@ -5,4 +5,5 @@ dump/*
5
5
  !log/.keep
6
6
  !dump/.keep
7
7
  *.gem
8
- .byebug_history
8
+ .byebug_history
9
+ *.code-workspace
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- travis-backup-for-v3 (0.1.0)
4
+ travis-backup-for-v3 (0.1.1)
5
5
  activerecord
6
6
  bootsnap
7
7
  pg
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # README
2
2
 
3
- *travis-backup-for-v3* is an application that helps with housekeeping and backup for Travis CI database v3.0. It removes requests and builds with their dependencies, as long as they are older than given threshold says.
3
+ *travis-backup-for-v3* is an application that helps with housekeeping and backup for Travis CI database v3.0. By default it removes requests and builds with their dependencies, as long as they are older than given threshold says (and backups them in files, if this option is active). It can also be used to remove specified users, organizations or repositories with their dependencies.
4
4
 
5
5
  ### Installation and run
6
6
 
@@ -55,6 +55,8 @@ backup.run(repo_id: 1)
55
55
 
56
56
  #### Special modes
57
57
 
58
+ Using `--user_id`, `--org_id` or `--repo_id` flag without setting `--threshold` results in removing the specified user/organization/repository with all its dependencies. It can be combined with `--backup` flag in order to save removed data in files.
59
+
58
60
  Using `--dry_run` flag you can check which data would be removed by gem, but without removing them actually. Instead of that reports will be printed on standard output. This flag can be also combined with special modes.
59
61
 
60
62
  ### Configuration options
data/db/schema.sql CHANGED
@@ -4,13 +4,11 @@ CREATE SCHEMA public;
4
4
 
5
5
  SET statement_timeout = 0;
6
6
  SET lock_timeout = 0;
7
- SET idle_in_transaction_session_timeout = 0;
8
7
  SET client_encoding = 'UTF8';
9
8
  SET standard_conforming_strings = on;
10
9
  SELECT pg_catalog.set_config('search_path', '', false);
11
10
  SET check_function_bodies = false;
12
11
  SET client_min_messages = warning;
13
- SET row_security = off;
14
12
 
15
13
  --
16
14
  -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
@@ -17,30 +17,30 @@ class Backup
17
17
  end
18
18
 
19
19
  def remove_heavy_data_for_repo(repository)
20
- remove_repo_builds(repository)
20
+ # remove_repo_builds(repository)
21
21
  remove_repo_requests(repository)
22
22
  end
23
23
 
24
- def remove_repo_builds(repository) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
25
- threshold = @config.threshold.to_i.months.ago.to_datetime
26
- builds_to_remove = repository.builds.where('created_at < ?', threshold)
24
+ # def remove_repo_builds(repository) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
25
+ # threshold = @config.threshold.to_i.months.ago.to_datetime
26
+ # builds_to_remove = repository.builds.where('created_at < ?', threshold)
27
27
 
28
- builds_dependencies = builds_to_remove.map do |build|
29
- result = build.ids_of_all_dependencies(dependencies_to_filter, :without_parents)
30
- result.add(:build, build.id)
31
- result
32
- end.compact
28
+ # builds_dependencies = builds_to_remove.map do |build|
29
+ # result = build.ids_of_all_dependencies(dependencies_to_filter, :without_parents)
30
+ # result.add(:build, build.id)
31
+ # result
32
+ # end.compact
33
33
 
34
- ids_to_remove = IdHash.join(*builds_dependencies)
35
- @subfolder = "repository_#{repository.id}_old_builds_#{current_time_for_subfolder}"
34
+ # ids_to_remove = IdHash.join(*builds_dependencies)
35
+ # @subfolder = "repository_#{repository.id}_old_builds_#{current_time_for_subfolder}"
36
36
 
37
- unless @config.dry_run
38
- nullified_rels = builds_to_remove&.map(&:nullify_default_dependencies)&.flatten
39
- save_nullified_rels_to_file(build: nullified_rels) if @config.if_backup
40
- end
37
+ # unless @config.dry_run
38
+ # nullified_rels = builds_to_remove&.map(&:nullify_default_dependencies)&.flatten
39
+ # save_nullified_rels_to_file(build: nullified_rels) if @config.if_backup
40
+ # end
41
41
 
42
- process_ids_to_remove(ids_to_remove)
43
- end
42
+ # process_ids_to_remove(ids_to_remove)
43
+ # end
44
44
 
45
45
  def remove_repo_requests(repository)
46
46
  threshold = @config.threshold.to_i.months.ago.to_datetime
@@ -61,11 +61,97 @@ class Backup
61
61
  end
62
62
 
63
63
  ids_to_remove = IdHash.join(*(requests_dependencies))
64
+ orphaned_ids = orphaned_configs_to_remove(repository, ids_to_remove)
65
+ ids_to_remove.join(orphaned_ids)
64
66
  process_ids_to_remove(ids_to_remove)
65
67
  end
66
68
 
67
69
  private
68
70
 
71
+ def find_config_ids_orphaned_now(model1:, model2:, repository:, foreign_key:, ids_to_remove:)
72
+ ids_to_exclude = ids_to_remove[model2.table_name.singularize.to_sym].join(', ')
73
+
74
+ orphaned_earlier = model1.find_by_sql(%{
75
+ select a.id
76
+ from #{model1.table_name} as a
77
+ left join #{model2.table_name} as b on
78
+ a.id = b.#{foreign_key}
79
+ where a.repository_id = #{repository.id}
80
+ group by a.id
81
+ having count(b.id) = 0;
82
+ }).map { |x| x.id }
83
+
84
+
85
+ all_orphaned = model1.find_by_sql(%{
86
+ select a.id
87
+ from #{model1.table_name} as a
88
+ left join #{model2.table_name} as b on
89
+ a.id = b.#{foreign_key} and b.id not in (#{ids_to_exclude})
90
+ where a.repository_id = #{repository.id}
91
+ group by a.id
92
+ having count(b.id) = 0;
93
+ }).map { |x| x.id }
94
+
95
+ all_orphaned - orphaned_earlier
96
+ end
97
+
98
+ def orphaned_configs_to_remove(repository, ids_to_remove)
99
+ if ids_to_remove[:request]
100
+ request_config_ids = find_config_ids_orphaned_now(
101
+ model1: RequestConfig,
102
+ model2: Request,
103
+ repository: repository,
104
+ foreign_key: 'config_id',
105
+ ids_to_remove: ids_to_remove
106
+ )
107
+ request_yaml_config_ids = find_config_ids_orphaned_now(
108
+ model1: RequestYamlConfig,
109
+ model2: Request,
110
+ repository: repository,
111
+ foreign_key: 'yaml_config_id',
112
+ ids_to_remove: ids_to_remove
113
+ )
114
+ end
115
+
116
+ if ids_to_remove[:request_raw_configuration]
117
+ request_raw_config_ids = find_config_ids_orphaned_now(
118
+ model1: RequestRawConfig,
119
+ model2: RequestRawConfiguration,
120
+ repository: repository,
121
+ foreign_key: 'request_raw_config_id',
122
+ ids_to_remove: ids_to_remove
123
+ )
124
+ end
125
+
126
+ if ids_to_remove[:build]
127
+ build_config_ids = find_config_ids_orphaned_now(
128
+ model1: BuildConfig,
129
+ model2: Build,
130
+ repository: repository,
131
+ foreign_key: 'config_id',
132
+ ids_to_remove: ids_to_remove
133
+ )
134
+ end
135
+
136
+ if ids_to_remove[:job]
137
+ job_config_ids = find_config_ids_orphaned_now(
138
+ model1: JobConfig,
139
+ model2: Job,
140
+ repository: repository,
141
+ foreign_key: 'config_id',
142
+ ids_to_remove: ids_to_remove
143
+ )
144
+ end
145
+
146
+ orphaned_ids = IdHash.new
147
+ orphaned_ids.add(:request_config, *request_config_ids)
148
+ orphaned_ids.add(:request_yaml_config, *request_yaml_config_ids)
149
+ orphaned_ids.add(:request_raw_config, *request_raw_config_ids)
150
+ orphaned_ids.add(:build_config, *build_config_ids)
151
+ orphaned_ids.add(:job_config, *job_config_ids)
152
+ orphaned_ids
153
+ end
154
+
69
155
  def process_ids_to_remove(ids_to_remove)
70
156
  if @config.dry_run
71
157
  @dry_run_reporter.add_to_report(ids_to_remove.with_table_symbols)
@@ -13,7 +13,6 @@ module SaveIdHashToFile
13
13
 
14
14
  def save_ids_batch_to_file(name, ids_batch)
15
15
  model = Model.get_model(name)
16
-
17
16
  export = {}
18
17
  export[:table_name] = model.table_name
19
18
  export[:data] = ids_batch.map do |id|
@@ -7,7 +7,7 @@ module SaveNullifiedRelsToFile
7
7
  @file_index = 1
8
8
 
9
9
  rels_hash.each do |name, rels|
10
- rels&.compact&.each_slice(@config.limit.to_i) do |rels_batch|
10
+ rels&.compact&.sort{|a, b| a.to_s <=> b.to_s}&.each_slice(@config.limit.to_i) do |rels_batch|
11
11
  save_rels_batch_to_file(name, rels_batch)
12
12
  end
13
13
  end
@@ -18,7 +18,7 @@ module SaveNullifiedRelsToFile
18
18
 
19
19
  export = {}
20
20
  export[:table_name] = model.table_name
21
- export[:nullified_relationships] = rels_batch
21
+ export[:nullified_relationships]
22
22
 
23
23
  content = JSON.pretty_generate(export)
24
24
  file_name = "nullified_relationships/build_#{@file_index}.json"
data/lib/config.rb CHANGED
@@ -129,9 +129,10 @@ class Config
129
129
  end
130
130
 
131
131
  def check_values
132
- if !@move_logs && !@remove_orphans && !@threshold && !@user_id && !@org_id && !@repo_id && !@load_from_files
132
+ if !@threshold && !@user_id && !@org_id && !@repo_id && !@load_from_files
133
133
  message = abort_message("Please provide the threshold argument. Data younger than it will be omitted. " +
134
- "Threshold defines number of months from now.")
134
+ "Threshold defines number of months from now. Alternatively you can define user_id, org_id or repo_id " +
135
+ "to remove whole user, organization or repository with all dependencies.")
135
136
  abort message
136
137
  end
137
138
 
@@ -139,21 +140,15 @@ class Config
139
140
  message = abort_message("Please provide proper database URL.")
140
141
  abort message
141
142
  end
142
-
143
- if (@move_logs && !@destination_db_url)
144
- abort "\nFor moving logs you need to specify your destination database. Example usage:\n" +
145
- "\n $ bin/travis_backup 'postgres://source_url' --move_logs --destination_db_url 'postgres://destination_url'\n" +
146
- "\nor using in code:\n" +
147
- "\n Backup.new(database_url: 'postgres://source_url', destination_db_url: 'postgres://destination_url', move_logs: true)\n" +
148
- "\nYou can also set it using environment variables or configuration files.\n"
149
- end
150
143
  end
151
144
 
152
145
  def abort_message(intro)
153
146
  "\n#{intro}\n\nExample usage:\n"+
154
- "\n $ bin/travis_backup 'postgres://my_database_url' --threshold 6\n" +
147
+ "\n $ travis_backup_for_v3 'postgres://my_database_url' --threshold 6" +
148
+ "\n $ travis_backup_for_v3 'postgres://my_database_url' --user_id 1\n" +
155
149
  "\nor using in code:\n" +
156
- "\n Backup.new(database_url: 'postgres://my_database_url', threshold: 6)\n" +
150
+ "\n Backup.new(database_url: 'postgres://my_database_url', threshold: 6)" +
151
+ "\n Backup.new(database_url: 'postgres://my_database_url', user_id: 1)\n" +
157
152
  "\nYou can also set it using environment variables or configuration files.\n"
158
153
  end
159
154
 
data/lib/db_helper.rb CHANGED
@@ -18,10 +18,14 @@ class DbHelper
18
18
  result
19
19
  end
20
20
 
21
- def do_without_triggers
21
+ def self.do_without_triggers
22
22
  ActiveRecord::Base.connection.execute('set session_replication_role = replica;')
23
23
  result = yield
24
24
  ActiveRecord::Base.connection.execute('set session_replication_role = default;')
25
25
  result
26
26
  end
27
+
28
+ def do_without_triggers(&block)
29
+ self.class.do_without_triggers(&block)
30
+ end
27
31
  end
data/lib/models/abuse.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Abuse < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :owner, polymorphic: true
7
9
  belongs_to :request
8
10
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class BetaMigrationRequest < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :owner, polymorphic: true
7
9
  has_many :organizations
8
10
  end
data/lib/models/branch.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Branch < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :last_build, foreign_key: :last_build_id, class_name: 'Build'
7
9
  belongs_to :repository
8
10
  has_many :builds
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class Broadcast < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :recipient, polymorphic: true
7
9
  end
data/lib/models/build.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Build < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  belongs_to :owner, polymorphic: true
8
10
  belongs_to :sender, polymorphic: true
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class BuildConfig < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  has_many :builds, foreign_key: :config_id, class_name: 'Build'
8
10
  has_many :deleted_builds, foreign_key: :config_id, class_name: 'DeletedBuild'
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Cancellation < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :subscription
7
9
  belongs_to :user
8
10
  end
data/lib/models/commit.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Commit < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :related_branch, foreign_key: :branch_id, class_name: 'Branch'
7
9
  belongs_to :repository
8
10
  belongs_to :tag
data/lib/models/cron.rb CHANGED
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class Cron < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :branch
7
9
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedBuild < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  belongs_to :owner, polymorphic: true
8
10
  belongs_to :sender, polymorphic: true
@@ -14,16 +16,7 @@ class DeletedBuild < Model
14
16
  belongs_to :build_config, foreign_key: :config_id, class_name: 'BuildConfig'
15
17
  self.primary_key = 'id'
16
18
 
17
- # has_many :jobs, -> { order('id') }, as: :source, dependent: :destroy
18
- # has_many :repos_for_that_this_build_is_current, foreign_key: :current_build_id, dependent: :destroy, class_name: 'Repository'
19
- # has_many :repos_for_that_this_build_is_last, foreign_key: :last_build_id, class_name: 'Repository'
20
- # has_many :tags_for_that_this_build_is_last, foreign_key: :last_build_id, class_name: 'Tag'
21
- # has_many :branches_for_that_this_build_is_last, foreign_key: :last_build_id, class_name: 'Branch'
22
- # has_many :stages
23
19
 
24
- # has_many :deleted_jobs, -> { order('id') }, as: :source, dependent: :destroy
25
- # has_many :deleted_tags_for_that_this_build_is_last, foreign_key: :last_build_id, class_name: 'DeletedTag'
26
- # has_many :deleted_stages
27
20
 
28
21
  # def self.default_dependencies_symbols_to_nullify
29
22
  # [
@@ -3,8 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedBuildConfig < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  self.primary_key = 'id'
8
- # has_many :builds, foreign_key: :config_id, class_name: 'Build'
9
- # has_many :deleted_builds, foreign_key: :config_id, class_name: 'DeletedBuild'
10
10
  end
@@ -3,15 +3,11 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedCommit < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :related_branch, foreign_key: :branch_id, class_name: 'Branch'
7
9
  belongs_to :repository
8
10
  belongs_to :tag
9
11
  self.primary_key = 'id'
10
- # has_many :builds
11
- # has_many :jobs
12
- # has_many :requests
13
12
 
14
- # has_many :deleted_builds
15
- # has_many :deleted_jobs
16
- # has_many :deleted_requests
17
13
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedJob < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :source, polymorphic: true
7
9
  belongs_to :owner, polymorphic: true
8
10
  belongs_to :repository
@@ -10,6 +12,4 @@ class DeletedJob < Model
10
12
  belongs_to :stage
11
13
  belongs_to :job_config, foreign_key: :config_id, class_name: 'JobConfig'
12
14
  self.primary_key = 'id'
13
- # has_many :queueable_jobs
14
- # has_many :job_versions
15
15
  end
@@ -3,8 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedJobConfig < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  self.primary_key = 'id'
8
- # has_many :jobs, foreign_key: :config_id, class_name: 'Job'
9
- # has_many :deleted_jobs, foreign_key: :config_id, class_name: 'DeletedJob'
10
10
  end
@@ -3,10 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedPullRequest < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  self.primary_key = 'id'
8
- # has_many :requests
9
- # has_many :builds
10
- # has_many :deleted_requests
11
- # has_many :deleted_builds
12
10
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedRequest < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :owner, polymorphic: true
7
9
  belongs_to :sender, polymorphic: true
8
10
  belongs_to :repository
@@ -13,14 +15,4 @@ class DeletedRequest < Model
13
15
  belongs_to :request_yaml_configs
14
16
  belongs_to :request_configs
15
17
  self.primary_key = 'id'
16
- # has_many :abuses
17
- # has_many :messages, as: :subject
18
- # has_many :jobs, as: :source
19
- # has_many :builds
20
- # has_many :request_payloads
21
- # has_many :request_raw_configurations
22
- # has_many :deleted_jobs, as: :source
23
- # has_many :deleted_builds
24
- # has_many :deleted_request_payloads
25
- # has_many :deleted_request_raw_configurations
26
18
  end
@@ -3,8 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedRequestConfig < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  self.primary_key = 'id'
8
- # has_many :requests, foreign_key: :config_id, class_name: 'Request'
9
- # has_many :deleted_requests, foreign_key: :config_id, class_name: 'DeletedRequest'
10
10
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedRequestPayload < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :request
7
9
  self.primary_key = 'id'
8
10
  end
@@ -3,8 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedRequestRawConfig < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  self.primary_key = 'id'
8
- # has_many :request_raw_configurations
9
- # has_many :deleted_request_raw_configurations
10
10
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedRequestRawConfiguration < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :request_raw_configs
7
9
  belongs_to :requests
8
10
  self.primary_key = 'id'
@@ -3,8 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedRequestYamlConfig < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  self.primary_key = 'id'
8
- # has_many :requests, foreign_key: :yaml_config_id, class_name: 'Request'
9
- # has_many :deleted_requests, foreign_key: :yaml_config_id, class_name: 'DeletedRequest'
10
10
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedSslKey < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  self.primary_key = 'id'
8
10
  end
@@ -3,8 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedStage < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :build
7
9
  self.primary_key = 'id'
8
- # has_many :jobs
9
- # has_many :deleted_jobs
10
10
  end
@@ -3,13 +3,9 @@
3
3
  require 'model'
4
4
 
5
5
  class DeletedTag < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :last_build, foreign_key: :last_build_id, class_name: 'Build'
7
9
  belongs_to :repository
8
10
  self.primary_key = 'id'
9
- # has_many :builds
10
- # has_many :commits
11
- # has_many :requests
12
- # has_many :deleted_builds
13
- # has_many :deleted_commits
14
- # has_many :deleted_requests
15
11
  end
data/lib/models/email.rb CHANGED
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class Email < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :user
7
9
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class EmailUnsubscribe < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  belongs_to :user
8
10
  end
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class Installation < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :owner, polymorphic: true
7
9
  end
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class Invoice < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :subscription
7
9
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class JobConfig < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  has_many :jobs, foreign_key: :config_id, class_name: 'Job'
8
10
  has_many :deleted_jobs, foreign_key: :config_id, class_name: 'DeletedJob'
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class JobVersion < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :job
7
9
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Membership < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :organization
7
9
  belongs_to :user
8
10
  end
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class Message < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :subject, polymorphic: true
7
9
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Organization < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :beta_migration_request
7
9
  has_many :builds_for_that_this_organization_is_owner, as: :owner, class_name: 'Build'
8
10
  has_many :builds_for_that_this_organization_is_sender, as: :sender, class_name: 'Build'
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class OwnerGroup < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :owner, polymorphic: true
7
9
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Permission < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  belongs_to :user
8
10
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class PullRequest < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  has_many :requests
8
10
  has_many :builds
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class QueueableJob < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :job
7
9
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class RepoCount < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  self.primary_key = 'repository_id'
8
10
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Repository < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :owner, polymorphic: true
7
9
  belongs_to :current_build, foreign_key: :current_build_id, class_name: 'Build'
8
10
  belongs_to :last_build, foreign_key: :last_build_id, class_name: 'Build'
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Request < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :owner, polymorphic: true
7
9
  belongs_to :sender, polymorphic: true
8
10
  belongs_to :repository
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class RequestConfig < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  has_many :requests, foreign_key: :config_id, class_name: 'Request'
8
10
  has_many :deleted_requests, foreign_key: :config_id, class_name: 'DeletedRequest'
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class RequestPayload < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :request
7
9
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class RequestRawConfig < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  has_many :request_raw_configurations
8
10
  has_many :deleted_request_raw_configurations
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class RequestRawConfiguration < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :request_raw_configs
7
9
  belongs_to :requests
8
10
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class RequestYamlConfig < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  has_many :requests, foreign_key: :yaml_config_id, class_name: 'Request'
8
10
  has_many :deleted_requests, foreign_key: :yaml_config_id, class_name: 'DeletedRequest'
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class SslKey < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  end
data/lib/models/stage.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Stage < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :build
7
9
  has_many :jobs
8
10
  has_many :deleted_jobs
data/lib/models/star.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Star < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :repository
7
9
  belongs_to :user
8
10
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Subscription < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :owner, polymorphic: true
7
9
  has_many :invoices
8
10
  has_many :cancellations
data/lib/models/tag.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Tag < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :last_build, foreign_key: :last_build_id, class_name: 'Build'
7
9
  belongs_to :repository
8
10
  has_many :builds
data/lib/models/token.rb CHANGED
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class Token < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :user
7
9
  end
data/lib/models/trial.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class Trial < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :owner, polymorphic: true
7
9
  has_many :trial_allowances
8
10
  end
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class TrialAllowance < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :creator, polymorphic: true
7
9
  belongs_to :trial
8
10
  end
data/lib/models/user.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require 'model'
4
4
 
5
5
  class User < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  has_many :builds_for_that_this_user_is_owner, as: :owner, class_name: 'Build'
7
9
  has_many :builds_for_that_this_user_is_sender, as: :sender, class_name: 'Build'
8
10
  has_many :repositories, as: :owner
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class UserBetaFeature < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :user
7
9
  end
@@ -3,5 +3,7 @@
3
3
  require 'model'
4
4
 
5
5
  class UserUtmParam < Model
6
+ self.inheritance_column = :_type_disabled
7
+
6
8
  belongs_to :user
7
9
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'travis-backup-for-v3'
3
- s.version = '0.1.0'
3
+ s.version = '0.1.1'
4
4
  s.summary = 'Travis CI backup tool'
5
5
  s.authors = ['Karol Selak']
6
6
  s.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis-backup-for-v3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karol Selak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-25 00:00:00.000000000 Z
11
+ date: 2022-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -339,7 +339,6 @@ files:
339
339
  - tmp/.keep
340
340
  - travis-backup-for-v3.gemspec
341
341
  - vendor/.keep
342
- - workspace.code-workspace
343
342
  homepage:
344
343
  licenses:
345
344
  - Beerware
@@ -1,8 +0,0 @@
1
- {
2
- "folders": [
3
- {
4
- "path": "."
5
- }
6
- ],
7
- "settings": {}
8
- }