Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Set up migrations to take into account pre-existing users.

Matthew Kennedyed79c676b842
diff --git a/core/db/migrate/20210902110754_rename_column_access_hash_to_token.rb b/core/db/migrate/20210902110754_rename_column_access_hash_to_token.rb
new file mode 100644
index 0000000000..45a4fe532e
--- /dev/null
+++ b/core/db/migrate/20210902110754_rename_column_access_hash_to_token.rb
@@ -0,0 +1,7 @@
+class RenameColumnAccessHashToToken < ActiveRecord::Migration[5.2]
+ def change
+ if table_exists?(:spree_wishlists)
+ t.rename :access_hash, :token if column_exists?(:spree_wishlists, :access_hash)
+ end
+ end
+end
diff --git a/core/db/migrate/20210902110757_create_spree_wishlists.rb b/core/db/migrate/20210902110757_create_spree_wishlists.rb
new file mode 100644
index 0000000000..66cce7a5b7
--- /dev/null
+++ b/core/db/migrate/20210902110757_create_spree_wishlists.rb
@@ -0,0 +1,16 @@
+class CreateSpreeWishlists < ActiveRecord::Migration[5.2]
+ def change
+ create_table :spree_wishlists, if_not_exists: true do |t|
+ t.references :user
+
+ t.column :name, :string
+ t.column :token, :string
+ t.column :is_private, :boolean, default: true, null: false
+ t.column :is_default, :boolean, default: false, null: false
+
+ t.timestamps
+ end
+
+ add_index :spree_wishlists, [:user_id, :is_default] unless index_exists?(:spree_wishlists, [:user_id, :is_default])
+ end
+end
diff --git a/core/db/migrate/20210902123011_create_spree_wished_products.rb b/core/db/migrate/20210902123011_create_spree_wished_products.rb
new file mode 100644
index 0000000000..c4d627fe37
--- /dev/null
+++ b/core/db/migrate/20210902123011_create_spree_wished_products.rb
@@ -0,0 +1,17 @@
+class CreateSpreeWishedProducts < ActiveRecord::Migration[5.2]
+ def change
+ create_table :spree_wished_products, if_not_exists: true do |t|
+ t.references :variant
+ t.references :wishlist
+
+ t.column :quantity, :integer, default: 1, null: false
+ t.column :remark, :text
+
+ t.timestamps
+ end
+
+ add_index :spree_wished_products, :variant_id unless index_exists?(:spree_wished_products, :variant_id)
+ add_index :spree_wished_products, :wishlist_id unless index_exists?(:spree_wished_products, :wishlist_id)
+ end
+end
+