card 1.105.6 → 1.106.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/config/initializers/02_patches/active_record.rb +2 -2
  4. data/db/schema.rb +5 -13
  5. data/lib/card/codename.rb +8 -0
  6. data/lib/card/director/store.rb +1 -1
  7. data/lib/card/model/save_helper/save_helper_helper.rb +6 -2
  8. data/lib/card/query/abstract_query/tie.rb +14 -0
  9. data/lib/card/query/card_query/interpretation.rb +26 -3
  10. data/lib/card/query/reference_query.rb +4 -4
  11. data/lib/card/set.rb +27 -0
  12. data/lib/cardio/generators/base.rb +1 -1
  13. data/lib/cardio/migration/assumption.rb +29 -0
  14. data/lib/cardio/migration/schema.rb +12 -0
  15. data/lib/cardio/migration/stamp.rb +31 -0
  16. data/lib/cardio/migration/transform.rb +44 -0
  17. data/lib/cardio/migration.rb +60 -74
  18. data/lib/cardio/mod/eat/edibles.rb +8 -2
  19. data/lib/cardio/mod/eat.rb +2 -1
  20. data/lib/cardio/mod/sow.rb +3 -1
  21. data/lib/cardio/mod.rb +5 -2
  22. data/lib/cardio/railtie.rb +6 -5
  23. data/lib/cardio/seed.rb +3 -6
  24. data/lib/generators/migration/USAGE +10 -11
  25. data/lib/generators/migration/migration_generator.rb +26 -24
  26. data/lib/generators/migration/templates/card_migration.erb +1 -3
  27. data/mod/core/data/fixtures/real/transform_migrations.yml +351 -0
  28. data/mod/core/data/recode.yml +7 -0
  29. data/{db/migrate → mod/core/data/schema}/20110511221913_require_earlier_migrations.rb +3 -3
  30. data/{db/migrate → mod/core/data/schema}/20120105203350_require_1_8_migrations.rb +1 -1
  31. data/{db/migrate → mod/core/data/schema}/20121111025347_require_1_10_migrations.rb +1 -1
  32. data/{db/migrate → mod/core/data/schema}/20121118114000_split_link_type.rb +1 -1
  33. data/{db/migrate → mod/core/data/schema}/20121118115000_update_link_type.rb +1 -1
  34. data/{db/migrate → mod/core/data/schema}/20130106052640_table_cleanup.rb +1 -1
  35. data/{db/migrate → mod/core/data/schema}/20130109015336_trunk_left.rb +1 -1
  36. data/{db/migrate → mod/core/data/schema}/20140822073704_create_new_revision_tables.rb +1 -1
  37. data/mod/core/data/schema/20141001105348_move_revisions_to_actions.rb +87 -0
  38. data/{db/migrate → mod/core/data/schema}/20141216053032_better_index_names.rb +10 -4
  39. data/{db/migrate → mod/core/data/schema}/20150724210803_add_comment_to_actions.rb +1 -1
  40. data/{db/migrate → mod/core/data/schema}/20151105225559_more_space_for_db_content.rb +1 -1
  41. data/{db/migrate → mod/core/data/schema}/20160122153608_new_indices.rb +1 -1
  42. data/{db/migrate → mod/core/data/schema}/20170908114442_create_delayed_jobs.rb +1 -1
  43. data/{db/migrate → mod/core/data/schema}/20170908114452_increase_text_size_for_delayed_jobs.rb +1 -1
  44. data/{db/migrate → mod/core/data/schema}/20180514152037_add_card_virtuals_table.rb +1 -1
  45. data/{db/migrate → mod/core/data/schema}/20190116170824_add_left_key_to_card_virtuals.rb +1 -1
  46. data/{db/migrate → mod/core/data/schema}/20190131223248_add_codename_index.rb +1 -1
  47. data/{db/migrate → mod/core/data/schema}/20190929202325_rename_present_in_reference_table.rb +1 -1
  48. data/{db/migrate → mod/core/data/schema}/20200718051236_compound_names_do_not_store_name_and_key.rb +1 -1
  49. data/{db/migrate → mod/core/data/schema}/20200805200729_add_unique_pair_indices.rb +1 -3
  50. data/{db/migrate → mod/core/data/schema}/20211128040849_virtuals_updated_at.rb +1 -1
  51. data/{db/migrate → mod/core/data/schema}/20221031182227_remove_referee_key_requirement.rb +1 -1
  52. data/mod/core/data/test.yml +4 -4
  53. data/{db/migrate_core_cards → mod/core/data/transform}/20120611203506_rails_inflection_updates.rb +10 -6
  54. data/mod/core/data/transform/20130411191151_renaming_for_menu.rb +17 -0
  55. data/mod/core/data/transform/20130920214038_jsonize_tinymce.rb +28 -0
  56. data/{db/migrate_core_cards → mod/core/data/transform}/20130920291703_update_stylesheets.rb +1 -1
  57. data/mod/core/data/transform/20140307231621_user_data_to_cards.rb +40 -0
  58. data/{db/migrate_core_cards → mod/core/data/transform}/20140317035504_account_requests_to_signups.rb +1 -1
  59. data/{db/migrate_core_cards → mod/core/data/transform}/20141204061304_watchers_to_following.rb +1 -1
  60. data/{db/migrate_core_cards → mod/core/data/transform}/20141208132416_partial_reference_type.rb +1 -1
  61. data/{db/migrate_core_cards → mod/core/data/transform}/20150220134731_following_to_follow_rule.rb +1 -1
  62. data/{db/migrate_core_cards → mod/core/data/transform}/20150429090551_search_card_context.rb +1 -1
  63. data/{db/migrate_core_cards → mod/core/data/transform}/20150510031118_fix_skin_codenames.rb +2 -2
  64. data/{db/migrate_core_cards → mod/core/data/transform}/20150724123438_update_file_and_image_cards.rb +2 -2
  65. data/{db/migrate_core_cards → mod/core/data/transform}/20150807205221_create_references_for_search_cards.rb +1 -1
  66. data/mod/core/data/transform/20150824135418_update_file_history.rb +33 -0
  67. data/{db/migrate_core_cards → mod/core/data/transform}/20160811115836_rename_stats_to_admin.rb +1 -1
  68. data/{db/migrate_core_cards → mod/core/data/transform}/20160914132636_fix_mod_files.rb +1 -1
  69. data/{db/migrate_core_cards → mod/core/data/transform}/20161103154836_update_keys.rb +3 -3
  70. data/{db/migrate_core_cards → mod/core/data/transform}/20170830210517_correct_signup_success_message.rb +1 -1
  71. data/{db/migrate_core_cards → mod/core/data/transform}/20180905061537_migrate_layouts.rb +1 -1
  72. data/{db/migrate_core_cards → mod/core/data/transform}/20190125125150_add_script_rules_card.rb +1 -1
  73. data/{db/migrate_core_cards → mod/core/data/transform}/20190320091257_upgrade_recaptcha_to_v3.rb +1 -1
  74. data/{db/migrate_core_cards → mod/core/data/transform}/20190322095534_remove_toolbar_cards.rb +1 -1
  75. data/{db/migrate_core_cards → mod/core/data/transform}/20190502130029_add_shark_and_help_desk_role.rb +2 -1
  76. data/{db/migrate_core_cards → mod/core/data/transform}/20190528131330_enabled_roles.rb +1 -1
  77. data/{db/migrate_core_cards → mod/core/data/transform}/20190625153616_pointer_overhaul.rb +1 -1
  78. data/{db/migrate_core_cards → mod/core/data/transform}/20190718140126_add_guides.rb +1 -1
  79. data/{db/migrate_core_cards → mod/core/data/transform}/20190822093633_move_help_text_to_code.rb +3 -1
  80. data/{db/migrate_core_cards → mod/core/data/transform}/20190829205148_remove_add_help.rb +1 -1
  81. data/mod/core/data/transform/20190902193208_input_type.rb +10 -0
  82. data/{db/migrate_core_cards → mod/core/data/transform}/20190904174403_token_upgrade.rb +2 -2
  83. data/{db/migrate_core_cards → mod/core/data/transform}/20190909104250_add_cardtype_input_types.rb +2 -2
  84. data/{db/migrate_core_cards → mod/core/data/transform}/20191115160748_history_cleanup.rb +1 -1
  85. data/mod/core/data/transform/20230502094848_repair_all_references.rb +7 -0
  86. data/mod/core/lib/tasks/card/migrate.rake +79 -114
  87. data/mod/core/lib/tasks/card.rake +2 -4
  88. metadata +67 -71
  89. data/db/migrate/20130411210957_update_codenames.rb +0 -15
  90. data/db/migrate/20141001105348_move_revisions_to_actions.rb +0 -70
  91. data/db/migrate/20141121172918_rename_card_migration_table.rb +0 -15
  92. data/db/migrate/20141208132159_remove_present_from_reference_table.rb +0 -9
  93. data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +0 -47
  94. data/db/migrate_core_cards/20130920214038_jsonize_tinymce.rb +0 -15
  95. data/db/migrate_core_cards/20140307231621_user_data_to_cards.rb +0 -28
  96. data/db/migrate_core_cards/20150824135418_update_file_history.rb +0 -24
  97. data/db/migrate_core_cards/20190902193208_input_type.rb +0 -15
  98. data/db/migrate_core_cards/20230502094848_repair_all_references.rb +0 -7
  99. data/lib/cardio/migration/core.rb +0 -11
  100. data/lib/cardio/migration/deck.rb +0 -0
  101. data/lib/cardio/migration/deck_structure.rb +0 -19
  102. data/lib/cardio/schema.rb +0 -96
  103. data/mod/core/data/fixtures/real/schema_migrations_core_cards.yml +0 -347
  104. data/mod/core/data/fixtures/real/schema_migrations_deck.yml +0 -1
  105. data/mod/core/data/fixtures/real/schema_migrations_deck_cards.yml +0 -5
@@ -1,5 +1,5 @@
1
1
  # add new indices for datetime and ref_type fields
2
- class NewIndices < ActiveRecord::Migration[4.2]
2
+ class NewIndices < Cardio::Migration::Schema
3
3
  def change
4
4
  add_index "card_references", ["ref_type"],
5
5
  name: "card_references_ref_type_index" # using: :btree
@@ -1,4 +1,4 @@
1
- class CreateDelayedJobs < ActiveRecord::Migration[5.1]
1
+ class CreateDelayedJobs < Cardio::Migration::Schema
2
2
  def self.up
3
3
  create_table :delayed_jobs, force: true do |table|
4
4
  table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
@@ -1,4 +1,4 @@
1
- class IncreaseTextSizeForDelayedJobs < ActiveRecord::Migration[5.1]
1
+ class IncreaseTextSizeForDelayedJobs < Cardio::Migration::Schema
2
2
  def self.up
3
3
  change_column :delayed_jobs, :handler, :text, limit: 16_777_215
4
4
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class AddCardVirtualsTable < ActiveRecord::Migration[4.2]
3
+ class AddCardVirtualsTable < Cardio::Migration::Schema
4
4
  def up
5
5
  drop_table :card_virtuals if table_exists? :card_virtuals
6
6
  create_table :card_virtuals do |t|
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class AddLeftKeyToCardVirtuals < ActiveRecord::Migration[4.2]
3
+ class AddLeftKeyToCardVirtuals < Cardio::Migration::Schema
4
4
  def up
5
5
  add_column :card_virtuals, :left_key, :string
6
6
  end
@@ -1,4 +1,4 @@
1
- class AddCodenameIndex < ActiveRecord::Migration[5.2]
1
+ class AddCodenameIndex < Cardio::Migration::Schema
2
2
  def up
3
3
  add_index :cards, [:codename], name: "cards_codename_index"
4
4
  end
@@ -1,4 +1,4 @@
1
- class RenamePresentInReferenceTable < ActiveRecord::Migration[4.2]
1
+ class RenamePresentInReferenceTable < Cardio::Migration::Schema
2
2
  def up
3
3
  rename_column :card_references, :present, :is_present
4
4
  end
@@ -1,4 +1,4 @@
1
- class CompoundNamesDoNotStoreNameAndKey < ActiveRecord::Migration[6.0]
1
+ class CompoundNamesDoNotStoreNameAndKey < Cardio::Migration::Schema
2
2
  def change
3
3
  change_column_null :cards, :name, true
4
4
  change_column_null :cards, :key, true
@@ -1,11 +1,9 @@
1
- class AddUniquePairIndices < ActiveRecord::Migration[6.0]
1
+ class AddUniquePairIndices < Cardio::Migration::Schema
2
2
  def change
3
3
  stash_duplicate_cards
4
4
  delete_duplicate_virtuals
5
5
  add_index :cards, %i[left_id right_id], unique: true
6
6
  add_index :card_virtuals, %i[left_id right_id], unique: true
7
-
8
- drop_table :users
9
7
  end
10
8
 
11
9
  private
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class VirtualsUpdatedAt < ActiveRecord::Migration[6.0]
3
+ class VirtualsUpdatedAt < Cardio::Migration::Schema
4
4
  def up
5
5
  add_column :card_virtuals, :updated_at, :datetime
6
6
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class RemoveRefereeKeyRequirement < ActiveRecord::Migration[6.0]
3
+ class RemoveRefereeKeyRequirement < Cardio::Migration::Schema
4
4
  def up
5
5
  change_column_null :card_references, :referee_key, true
6
6
  end
@@ -14,16 +14,16 @@
14
14
  - :name: B
15
15
  :content: Beta {{Z}}
16
16
  :user: Joe User
17
+ - :name:
18
+ - A
19
+ - B
20
+ :content: AlphaBeta
17
21
  - :name: T
18
22
  :content: Theta
19
23
  - :name: X
20
24
  :content: "[[A]] [[A+B]] [[T]]"
21
25
  - :name: Y
22
26
  :content: "{{B}} {{A+B}} {{A}} {{T}}"
23
- - :name:
24
- - A
25
- - B
26
- :content: AlphaBeta
27
27
  - :name:
28
28
  - A
29
29
  - B
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class RailsInflectionUpdates < Cardio::Migration::Core
3
+ class RailsInflectionUpdates < Cardio::Migration::Transform
4
4
  def word ar
5
5
  [/(?<=\W|_|^)#{ar[0]}(?=\W|_|$)/i, /(?<=\W|_|^)#{ar[1]}(?=\W|_|$)/i, ar[2]]
6
6
  end
@@ -19,17 +19,21 @@ class RailsInflectionUpdates < Cardio::Migration::Core
19
19
  twin.destroy
20
20
  yield
21
21
  elsif !card.trash
22
- raise Card::Error::Oops,
23
- "Your deck has two different cards with names '#{card.name}' and "\
24
- "'#{twin.name}'. After this update it's no longer possible to "\
25
- "differentiate between those two names. Please rename or delete one of "\
26
- "the two cards and run the update again."
22
+ unresolvable_name_collision! card, twin
27
23
  end
28
24
  else
29
25
  yield
30
26
  end
31
27
  end
32
28
 
29
+ def unresolvable_name_collision! card, twin
30
+ raise Card::Error::Oops,
31
+ "Your deck has two different cards with names '#{card.name}' and " \
32
+ "'#{twin.name}'. After this update it's no longer possible to " \
33
+ "differentiate between those two names. Please rename or delete one of " \
34
+ "the two cards and run the update again."
35
+ end
36
+
33
37
  def up
34
38
  card_names = Card.pluck(:name)
35
39
  apply_to_content = ::Set.new
@@ -0,0 +1,17 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class RenamingForMenu < Cardio::Migration::Transform
4
+ OLDNAMES = %w[
5
+ *links,
6
+ *inclusions,
7
+ *linkers
8
+ *includers
9
+ *plus cards
10
+ *plus parts
11
+ *editing
12
+ ].freeze
13
+
14
+ def up
15
+ OLDNAMES.each { |oldname| oldname.card&.delete! }
16
+ end
17
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class JsonizeTinymce < Cardio::Migration::Transform
4
+ def up
5
+ card = Card[:tiny_mce]
6
+ content = card.db_content
7
+ return if valid_json? content
8
+
9
+ card.content = cleaned_content content
10
+ card.save!
11
+ end
12
+
13
+ def cleaned_content content
14
+ cleaned_rows = content.strip.split(/\s*,\s+/).map do |row|
15
+ key, val = row.split(/\s*:\s*/)
16
+ val.gsub!(/"\s*\+\s*"/, "")
17
+ val.gsub! "'", '",'
18
+ %("#{key}":#{val})
19
+ end
20
+ %({\n#{cleaned_rows.join ",\n"}\n})
21
+ end
22
+
23
+ def valid_json? text
24
+ JSON.parse text
25
+ rescue JSON::ParserError
26
+ false
27
+ end
28
+ end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class UpdateStylesheets < Cardio::Migration::Core
3
+ class UpdateStylesheets < Cardio::Migration::Transform
4
4
  def up
5
5
  Card["*all+*style+file"]&.delete!
6
6
  end
@@ -0,0 +1,40 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class User < Cardio::Record
4
+ end
5
+
6
+ class UserDataToCards < Cardio::Migration::Transform
7
+ def up
8
+ puts "importing all user details (for those not in trash) into +*account attributes"
9
+ User.all.each do |user|
10
+ next unless (base = user.card_id.card)
11
+ puts "~ importing details for #{base.name}"
12
+ import_user_fields user, base
13
+ end
14
+ end
15
+
16
+ def import_user_fields user, base
17
+ date_args = date_args user
18
+ %i[email salt password status].each do |field|
19
+ cardname = [base.name, :account, field].cardname
20
+ next unless (content = field_content field, user)
21
+
22
+ import_user_field cardname, date_args, content
23
+ end
24
+ end
25
+
26
+ def date_args user
27
+ { created_at: user.created_at, updated_at: user.updated_at }
28
+ end
29
+
30
+ def field_content field, user
31
+ user_field = (field == :password ? :crypted_password : field)
32
+ user.send user_field
33
+ end
34
+
35
+ def import_user_field cardname, date_args, content
36
+ Card.create! date_args.merge(name: cardname, content: content)
37
+ rescue StandardError => e
38
+ puts "error importing #{cardname}: #{e.message}"
39
+ end
40
+ end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class AccountRequestsToSignups < Cardio::Migration::Core
3
+ class AccountRequestsToSignups < Cardio::Migration::Transform
4
4
  def up
5
5
  newname = "Sign up"
6
6
  newname = "*signup" if Card.exists? newname
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class WatchersToFollowing < Cardio::Migration::Core
3
+ class WatchersToFollowing < Cardio::Migration::Transform
4
4
  def up
5
5
  follower_hash = Hash.new { |h, v| h[v] = [] }
6
6
 
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class PartialReferenceType < Cardio::Migration::Core
3
+ class PartialReferenceType < Cardio::Migration::Transform
4
4
  def up
5
5
  Card::Reference.repair_all
6
6
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class FollowingToFollowRule < Cardio::Migration::Core
3
+ class FollowingToFollowRule < Cardio::Migration::Transform
4
4
  def up
5
5
  Card.search(right: { codename: "following" },
6
6
  left: { type: "user" }).each do |following_card|
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class SearchCardContext < Cardio::Migration::Core
3
+ class SearchCardContext < Cardio::Migration::Transform
4
4
  def up
5
5
  sep = /\W/
6
6
  replace = [
@@ -1,13 +1,13 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class FixSkinCodenames < Cardio::Migration::Core
3
+ class FixSkinCodenames < Cardio::Migration::Transform
4
4
  def up
5
5
  # This is needed because the bootswatch_themes migration removed codenames.
6
6
  # They were no longer needed for style handling but are still needed for images
7
7
  %w[bootstrap_default cerulean cosmo cyborg darkly flatly journal lumen paper readable
8
8
  sandstone simplex slate spacelab superhero united yeti].each do |theme_name|
9
9
  theme_name = "#{theme_name}_skin"
10
- Card.fetch(theme_name).update! codename: theme_name
10
+ Card.fetch(theme_name)&.update! codename: theme_name
11
11
  end
12
12
  end
13
13
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class UpdateFileAndImageCards < Cardio::Migration::Core
3
+ class UpdateFileAndImageCards < Cardio::Migration::Transform
4
4
  def up
5
5
  # use codenames for the filecards not for the left parts
6
6
  if (credit = Card[:credit]) && (card = credit.fetch(:image))
@@ -76,7 +76,7 @@ class UpdateFileAndImageCards < Cardio::Migration::Core
76
76
  journal_skin lumen_skin paper_skin readable_skin sandstone_skin
77
77
  simplex_skin slate_skin spacelab_skin superhero_skin united_skin
78
78
  yeti_skin].each do |name|
79
- next unless (card = Card[name.to_sym])
79
+ next unless (Card::Codename.exists?(name) && (card = name.to_sym.card))
80
80
 
81
81
  card.update! codename: nil
82
82
  if (card = Card.fetch name, :image)
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class CreateReferencesForSearchCards < Cardio::Migration::Core
3
+ class CreateReferencesForSearchCards < Cardio::Migration::Transform
4
4
  def up
5
5
  Card.where(
6
6
  type_id: Card::SearchTypeID
@@ -0,0 +1,33 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class UpdateFileHistory < Cardio::Migration::Transform
4
+ def up
5
+ Card.search(type: [:in, "file", "image"]).each { |card| update_actions card }
6
+ Card.search(right: { codename: "machine_output" }).each(&:delete!)
7
+ end
8
+
9
+ def update_actions card
10
+ card.actions.each do |action|
11
+ next unless (content_change = action.change :db_content)
12
+ next if content_change.new_record?
13
+
14
+ update_change_value card, content_change
15
+ end
16
+ end
17
+
18
+ def update_change_value card, content_change
19
+ original_filename, file_type, action_id, mod = content_change.value.split("\n")
20
+ return unless file_type.present? && action_id.present?
21
+
22
+ extension = ::File.extname original_filename
23
+ content_change.update! value: file_content_value(card, mod, action_id, extension)
24
+ end
25
+
26
+ def file_content_value card, mod, action_id, extension
27
+ if mod.present?
28
+ ":#{card.codename}/#{mod}#{extension}"
29
+ else
30
+ "~#{card.id}/#{action_id}#{extension}"
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class RenameStatsToAdmin < Cardio::Migration::Core
3
+ class RenameStatsToAdmin < Cardio::Migration::Transform
4
4
  def up
5
5
  return if Card::Codename.exist?(:admin) || !Card::Codename.exist?(:stats)
6
6
 
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class FixModFiles < Cardio::Migration::Core
3
+ class FixModFiles < Cardio::Migration::Transform
4
4
  def up
5
5
  Card.search(type: "image").each do |card|
6
6
  next unless card.coded?
@@ -1,8 +1,8 @@
1
- l# -*- encoding : utf-8 -*-
1
+ # -*- encoding : utf-8 -*-
2
2
 
3
- class UpdateKeys < Cardio::Migration::Core
3
+ class UpdateKeys < Cardio::Migration::Transform
4
4
  def up
5
- Card.pluck(:id, :name, :key).each do |id, name, key|
5
+ Card.where("name is not null").pluck(:id, :name, :key).each do |id, name, key|
6
6
  new_key = name.to_name.key
7
7
  next if new_key == key
8
8
 
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class CorrectSignupSuccessMessage < Cardio::Migration::Core
3
+ class CorrectSignupSuccessMessage < Cardio::Migration::Transform
4
4
  def up
5
5
  if (card = Card["signup success"]) && card.db_content.include?("{{*title}}")
6
6
  new_content = card.db_content.gsub "{{*title}}", "{{*title|core}}"
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class MigrateLayouts < Cardio::Migration::Core
3
+ class MigrateLayouts < Cardio::Migration::Transform
4
4
  def up
5
5
  Card.search referred_to_by: { right: :layout } do |card|
6
6
  create_head_rules card
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class AddScriptRulesCard < Cardio::Migration::Core
3
+ class AddScriptRulesCard < Cardio::Migration::Transform
4
4
  def up
5
5
  Card.ensure name: "script: rules",
6
6
  type_id: Card::CoffeeScriptID,
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class UpgradeRecaptchaToV3 < Cardio::Migration::Core
3
+ class UpgradeRecaptchaToV3 < Cardio::Migration::Transform
4
4
  def up
5
5
  update_card! %i[recaptcha_settings self structure],
6
6
  content: <<~STRING
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class RemoveToolbarCards < Cardio::Migration::Core
3
+ class RemoveToolbarCards < Cardio::Migration::Transform
4
4
  def up
5
5
  delete_code_card :activity_toolbar_button
6
6
  delete_code_card :rules_toolbar_button
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class AddSharkAndHelpDeskRole < Cardio::Migration::Core
3
+ class AddSharkAndHelpDeskRole < Cardio::Migration::Transform
4
4
  def up
5
5
  update_card! "Decker Menu", name: "Shark Menu"
6
6
  update_card! :ace, name: "*ace"
@@ -28,6 +28,7 @@ class AddSharkAndHelpDeskRole < Cardio::Migration::Core
28
28
 
29
29
  def delete_right_read_permissions
30
30
  %i[machine_output head script style solid_cache].each do |n|
31
+ next unless Card::Codename.exists? n
31
32
  delete_card [n, :right, :read]
32
33
  end
33
34
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class EnabledRoles < Cardio::Migration::Core
3
+ class EnabledRoles < Cardio::Migration::Transform
4
4
  def up
5
5
  Card.search type_id: Card::SessionID do |card|
6
6
  card.update_column :trash, true unless card.codename.present?
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class PointerOverhaul < Cardio::Migration::Core
3
+ class PointerOverhaul < Cardio::Migration::Transform
4
4
  def up
5
5
  unless Card::Codename[:mirrored_list]
6
6
  update "List", name: "Mirrored List",
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class AddGuides < Cardio::Migration
3
+ class AddGuides < Cardio::Migration::Transform
4
4
  GUIDE = <<-MD.strip_heredoc
5
5
  #### Editing Guide
6
6
 
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class MoveHelpTextToCode < Cardio::Migration::Core
3
+ class MoveHelpTextToCode < Cardio::Migration::Transform
4
4
  def up
5
5
  update_card! "*sidebar", codename: "sidebar"
6
6
  Card::Cache.reset_all
@@ -17,6 +17,7 @@ class MoveHelpTextToCode < Cardio::Migration::Core
17
17
  def remove_search_help_rules
18
18
  %i[created edited children includes refers_to links_to included_by linked_to_by
19
19
  referred_to_by mates editors follow].each do |trait|
20
+ next unless Card::Codename.exists? trait
20
21
  delete_card [trait, :right, :help]
21
22
  end
22
23
  end
@@ -31,6 +32,7 @@ class MoveHelpTextToCode < Cardio::Migration::Core
31
32
 
32
33
  def remove_self_help_rules *anchors
33
34
  anchors.each do |a|
35
+ next unless Card::Codename.exists? a
34
36
  delete_card [a, :self, :help]
35
37
  end
36
38
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class RemoveAddHelp < Cardio::Migration::Core
3
+ class RemoveAddHelp < Cardio::Migration::Transform
4
4
  def up
5
5
  Card.search(right: { codename: "add_help" },
6
6
  left: { type_id: Card::SetID }).each do |card|
@@ -0,0 +1,10 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class InputType < Cardio::Migration::Transform
4
+ def up
5
+ Card::Cache.reset_all
6
+
7
+ Card.ensure name: %i[all content_option_view], content: "smart_label"
8
+ Card.search right: :content_option_view, left: { not: :all }, &:delete!
9
+ end
10
+ end
@@ -1,8 +1,8 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class TokenUpgrade < Cardio::Migration::Core
3
+ class TokenUpgrade < Cardio::Migration::Transform
4
4
  def up
5
- update_card! :token, name: "*api key", codename: "api_key"
5
+ # update_card! :token, name: "*api key", codename: "api_key"
6
6
  delete_code_card :expiration
7
7
 
8
8
  %i[user signup].each do |type|
@@ -1,9 +1,9 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class AddCardtypeInputTypes < Cardio::Migration::Core
3
+ class AddCardtypeInputTypes < Cardio::Migration::Transform
4
4
  def up
5
5
  Card.ensure name: %i[input_type right default],
6
- type_id: Card::PointerID
6
+ type: :pointer
7
7
  Card.ensure name: %i[content_option_view right default],
8
8
  type_id: "smart label"
9
9
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- class HistoryCleanup < Cardio::Migration
3
+ class HistoryCleanup < Cardio::Migration::Transform
4
4
  def up
5
5
  delete_create_only_changes
6
6
  end
@@ -0,0 +1,7 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class RepairAllReferences < Cardio::Migration::Transform
4
+ def up
5
+ # Card::Reference.repair_all
6
+ end
7
+ end