easy_seeds 1.0.4 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/lib/easy_seeds/seeder.rb +1 -0
  3. data/lib/easy_seeds/version.rb +1 -1
  4. metadata +2 -53
  5. data/.DS_Store +0 -0
  6. data/.gitignore +0 -4
  7. data/README.md +0 -101
  8. data/demo/db/.DS_Store +0 -0
  9. data/demo/db/.gitignore +0 -1
  10. data/demo/db/migrate/20221220031557_create_users.rb +0 -16
  11. data/demo/db/migrate/20221229181317_create_restaurants.rb +0 -15
  12. data/demo/db/migrate/20221230024550_create_menus.rb +0 -9
  13. data/demo/db/migrate/20221230161702_create_menu_items.rb +0 -11
  14. data/demo/db/migrate/20230105193341_create_active_storage_tables.active_storage.rb +0 -57
  15. data/demo/db/migrate/20230107051041_create_reviews.rb +0 -10
  16. data/demo/db/migrate/20230107053024_create_carts.rb +0 -10
  17. data/demo/db/migrate/20230107161239_create_transactions.rb +0 -10
  18. data/demo/db/migrate/20230111045953_edit_restaurants.rb +0 -5
  19. data/demo/db/migrate/20230111051203_edit_restaurants_desc.rb +0 -5
  20. data/demo/db/migrate/20230111052037_add_descto_menu_items.rb +0 -5
  21. data/demo/db/migrate/20230111052640_add_header_to_menu_items.rb +0 -5
  22. data/demo/db/migrate/20230111053049_add_fk_carts.rb +0 -5
  23. data/demo/db/migrate/20230111170524_edit_transaction.rb +0 -5
  24. data/demo/db/migrate/20230112184231_create_locations.rb +0 -10
  25. data/demo/db/migrate/20230127004056_drop_carts.rb +0 -5
  26. data/demo/db/migrate/20230127004504_create_carts2.rb +0 -9
  27. data/demo/db/migrate/20230127004817_create_cart_items.rb +0 -10
  28. data/demo/db/migrate/20230129230534_remove_cart_index.rb +0 -6
  29. data/demo/db/migrate/20230129231213_edit_carts_index.rb +0 -5
  30. data/demo/db/migrate/20230201235823_remove_cart_item_index.rb +0 -6
  31. data/demo/db/migrate/20230201235957_edit_cart_items_index.rb +0 -5
  32. data/demo/db/migrate/20230203015313_remove_username.rb +0 -5
  33. data/demo/db/migrate/20230204005331_add_rest_avg_price.rb +0 -5
  34. data/demo/db/schema.rb +0 -149
  35. data/demo/db/seed_files/1_users_seeds.csv +0 -6
  36. data/demo/db/seed_files/2_restaurants_seeds.csv +0 -45
  37. data/demo/db/seed_files/3_menus_seeds.csv +0 -45
  38. data/demo/db/seed_files/4_menu_items_seeds.csv +0 -2085
  39. data/demo/db/seed_files/5_reviews_seeds.csv +0 -80
  40. data/demo/db/seed_files/6_carts_seeds.csv +0 -3
  41. data/demo/db/seed_files/7_cart_items_seeds.csv +0 -5
  42. data/demo/db/seed_files/8_transactions_seeds.csv +0 -4
  43. data/demo/db/seed_files/9_locations_seeds.csv +0 -2
  44. data/demo/db/seed_image_files/1_restaurant_image_seeds.csv +0 -45
  45. data/demo/db/seeds.rb +0 -45
  46. data/demo/seed_files/1_user_seeds_sample.csv +0 -5
  47. data/demo/seed_files/2_resturaunts_seeds_sample.csv +0 -6
  48. data/demo/seed_files/3_menu_seeds_sample.csv +0 -6
  49. data/demo/seed_files/4_menu_items_seed_sample.csv +0 -6
  50. data/demo/seed_image_files/.DS_Store +0 -0
  51. data/demo/seed_image_files/1_image_seed_sample.csv +0 -17
  52. data/demo/seed_image_files/2_image_seed_sample.csv +0 -18
  53. data/easy_seeds-1.0.0.gem +0 -0
  54. data/easy_seeds-1.0.1.gem +0 -0
  55. data/easy_seeds.gemspec +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 848b4cf13ea812068f5d945564ea457a1c7dbe5e73584372e39c04cd7a46c75f
4
- data.tar.gz: 001cbb8c8b6f8f9bf6a6902eb3ba25f11c81a2fc3facbcf3dc5bc3ead4adc4c5
3
+ metadata.gz: 21f9d58134e6fb217691898efca726216d539b87a824c04bd528ac78e68ae0b1
4
+ data.tar.gz: 58418295837cf281f771e0be99b6debc5784059313b889c4fe71872d620d874c
5
5
  SHA512:
6
- metadata.gz: 9473cc9116a4b01ed3bbc461dcd6fc520012fba18d3bb55f8899f081e390e016bafc725d0d722b60a3e5c79a427e0870550cd1d4221af8297a7ee4393f08fb92
7
- data.tar.gz: 4116ea2a029ec0293e1dfb42e54653c93cad0da67ae552288ad271a449aa586d0ef68f54d478ce42fca5b7e8b21f8e74c8eae5421c9942149f459cee827618dd
6
+ metadata.gz: b483065155f135b87f7a0e9ad715e411dbb28b09c37d51d99d671e4625b0a699bc7cd68cd38a7500d8f23b68fcd8f1b62272215d9c56832772b643da75b7d510
7
+ data.tar.gz: 4c92fe851d272c1eeddcd48596446365c334f9934e27f045039a4afbfca0dc9275054565c43c9828f4d9dc935abd9a55221d6540c07237b799a328ea5eaf70a7
@@ -18,6 +18,7 @@ module EasySeeds
18
18
 
19
19
  #Creates easy seed data for all classes that are passed in
20
20
  def self.create_easy_seed_data(class_names)
21
+ puts 'Creating easy seeds data'
21
22
  tables, table_strings = EasySeeds::CSVLoader.tables_from_csvs
22
23
 
23
24
  (0...tables.length).each do |i|
@@ -1,3 +1,3 @@
1
1
  module EasySeeds
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_seeds
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxwell Fong
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-04-04 00:00:00.000000000 Z
12
+ date: 2023-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: csv
@@ -34,57 +34,6 @@ executables: []
34
34
  extensions: []
35
35
  extra_rdoc_files: []
36
36
  files:
37
- - ".DS_Store"
38
- - ".gitignore"
39
- - README.md
40
- - demo/db/.DS_Store
41
- - demo/db/.gitignore
42
- - demo/db/migrate/20221220031557_create_users.rb
43
- - demo/db/migrate/20221229181317_create_restaurants.rb
44
- - demo/db/migrate/20221230024550_create_menus.rb
45
- - demo/db/migrate/20221230161702_create_menu_items.rb
46
- - demo/db/migrate/20230105193341_create_active_storage_tables.active_storage.rb
47
- - demo/db/migrate/20230107051041_create_reviews.rb
48
- - demo/db/migrate/20230107053024_create_carts.rb
49
- - demo/db/migrate/20230107161239_create_transactions.rb
50
- - demo/db/migrate/20230111045953_edit_restaurants.rb
51
- - demo/db/migrate/20230111051203_edit_restaurants_desc.rb
52
- - demo/db/migrate/20230111052037_add_descto_menu_items.rb
53
- - demo/db/migrate/20230111052640_add_header_to_menu_items.rb
54
- - demo/db/migrate/20230111053049_add_fk_carts.rb
55
- - demo/db/migrate/20230111170524_edit_transaction.rb
56
- - demo/db/migrate/20230112184231_create_locations.rb
57
- - demo/db/migrate/20230127004056_drop_carts.rb
58
- - demo/db/migrate/20230127004504_create_carts2.rb
59
- - demo/db/migrate/20230127004817_create_cart_items.rb
60
- - demo/db/migrate/20230129230534_remove_cart_index.rb
61
- - demo/db/migrate/20230129231213_edit_carts_index.rb
62
- - demo/db/migrate/20230201235823_remove_cart_item_index.rb
63
- - demo/db/migrate/20230201235957_edit_cart_items_index.rb
64
- - demo/db/migrate/20230203015313_remove_username.rb
65
- - demo/db/migrate/20230204005331_add_rest_avg_price.rb
66
- - demo/db/schema.rb
67
- - demo/db/seed_files/1_users_seeds.csv
68
- - demo/db/seed_files/2_restaurants_seeds.csv
69
- - demo/db/seed_files/3_menus_seeds.csv
70
- - demo/db/seed_files/4_menu_items_seeds.csv
71
- - demo/db/seed_files/5_reviews_seeds.csv
72
- - demo/db/seed_files/6_carts_seeds.csv
73
- - demo/db/seed_files/7_cart_items_seeds.csv
74
- - demo/db/seed_files/8_transactions_seeds.csv
75
- - demo/db/seed_files/9_locations_seeds.csv
76
- - demo/db/seed_image_files/1_restaurant_image_seeds.csv
77
- - demo/db/seeds.rb
78
- - demo/seed_files/1_user_seeds_sample.csv
79
- - demo/seed_files/2_resturaunts_seeds_sample.csv
80
- - demo/seed_files/3_menu_seeds_sample.csv
81
- - demo/seed_files/4_menu_items_seed_sample.csv
82
- - demo/seed_image_files/.DS_Store
83
- - demo/seed_image_files/1_image_seed_sample.csv
84
- - demo/seed_image_files/2_image_seed_sample.csv
85
- - easy_seeds-1.0.0.gem
86
- - easy_seeds-1.0.1.gem
87
- - easy_seeds.gemspec
88
37
  - lib/easy_seeds/csv_methods.rb
89
38
  - lib/easy_seeds/destroy.rb
90
39
  - lib/easy_seeds/easy_seeds.rb
data/.DS_Store DELETED
Binary file
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- easy_seeds-1.0.0.gem
2
- easy_seeds-1.0.1.gem
3
- easy_seeds-1.0.2.gem
4
- easy_seeds-1.0.3.gem
data/README.md DELETED
@@ -1,101 +0,0 @@
1
- # easy_seeds
2
- Easy seedes for Ruby on Rails projects. Allows the use of csv files for bulk seeding.
3
-
4
-
5
- # The Upshot
6
-
7
- Tired of the old fashion way of seeding your database? Have a lot of rows of data? No problem, just try and hard code all 500 rows by hand. Oh dear, where did I miss that comma?
8
- If that's been your Ruby on Rails seeding experience, then look no further, Easy Seeds has got you covered.
9
-
10
- With some slight modifications to your_project/db, you'll be on your way to a larger, faster, and more headache free seeding experience.
11
-
12
- # Setup instructions
13
-
14
- 1. Git clone or copy paste the easy_seeds.rb file into your rails /db folder. Remove the .git file to prevent nested repos.
15
- 2. Copy all your CSVs into a folder /db/seeds_resources folder. Your file names must be named the same as your tables. See the examples attached in the repo.
16
- 3. CSV files must be named in the the format "<number>_<tablename plural>.csv" e.g "1_users_seeds.csv". EasySeeds.create_easy_seed_data works by reading the table you want created in order of entry and creating them accordingly, so pay attention to how you name your .csv files.
17
- 4. Header collumn names follow the following format "name":"data_type". If a :"data_type" is not given, EasySeeds defaults to a string object.
18
- 5. require_relative "easy_seeds.rb" into your /db/seeds.rb file.
19
- 6. Initialize an array of class_names following the order your seed CSVs are arranged in /db/seeds/resources.
20
- 7. At the bottom of your your seeds.rb file call EasySeeds.create_easy_seed_data(class_names)
21
- 8. Refer to the example included in ./demo/db if you get stuck!
22
-
23
- ## CSV Seed_Files Setup
24
-
25
- See the samples for how CSV's are set up. The headers need to match the database column names exactly.
26
- Use the format -- column_name:data_type -- for the headers. easy_seeds will do type conversion for you. Default is "string" and does not need to be declared.
27
- Accepted data types: string, integer, float, boolean, date.
28
- If you need an additional data type ping Marcos or Max and we can update.
29
-
30
- ## CSV Image Setup
31
-
32
- Seed image files Require a Id, URL and Filename. You can copy these last two straight from the AWS console.
33
- the Id will attach the image path to that Id's object instance. See "Easy Seeder Setup" for information on file ordering.
34
-
35
- ## Easy Seeder Setup
36
-
37
- File order matters!
38
- Place your model names in class_names for each class you are making Seed Data for. Each class needs its own CSV.
39
-
40
- The order of class_names and the order of files in seed_files should match your migration order (to prevent null database constraint failures).
41
- EasySeeds.attach_images runs after all database instances are created. It uses the value in class_image_names
42
- to attach images to an instance of that Class_Name and Id.
43
-
44
- hit us up with questions.
45
-
46
-
47
- # Projects using easy seeds
48
-
49
- https://willow-8s24.onrender.com/
50
- https://suber-eats.onrender.com/
51
-
52
-
53
- # Common Preconditions:
54
-
55
- 1. table: Expects an array version of your table that corresponds to the name.
56
- Your table MUST be formated as an array containing multiple hashes, see the example from my menu_items class on github.
57
- Because of how this is set up, the variable name MUST be equivalent to the name of the table in migrations.
58
- 2. class_name: Expects the actual class name created in models. Expects an actual class variable.
59
- 3. table_string: Table name given as a string. Usually used for destroying tables ahead of import. Expects a string
60
-
61
- # Methods:
62
-
63
- (Produced with ChatGPT4, pending review)
64
-
65
- EasySeeds::CSVMethods
66
-
67
- The CSVMethods class provides methods for parsing and unpacking CSV files into usable seed data.
68
- Methods
69
-
70
- unpack_csvs(seed_file): Given a CSV file, returns an array of headers and an array of arrays containing data from the CSV.
71
- tables_from_csvs: Given a directory of CSV files, returns an array of arrays containing seed data and an array of table names.
72
-
73
- EasySeeds::Seeder
74
-
75
- The Seeder class provides methods for creating seed data.
76
- Methods
77
-
78
- single_seeder(table, class_name, table_string): Given a table (an array of hashes containing seed data), a class name (the name of the ActiveRecord class to seed), and a table string (the name of the table in the database), creates a single instance of seed data.
79
- create_easy_seed_data(class_names): Given an array of class names (the names of the ActiveRecord classes to seed), creates easy seed data for all of the classes.
80
-
81
- EasySeeds::Images
82
-
83
- The Images class provides methods for attaching images to seed data.
84
- Methods
85
-
86
- attach_images(class_image_names): Given an array of class names (the names of the ActiveRecord classes to attach images to), attaches images to the seed data for each class.
87
-
88
- EasySeeds::Destroy
89
-
90
- The Destroy class provides methods for destroying seed data.
91
- Methods
92
-
93
- destroy_table(class_name, table_string): Given a class name (the name of the ActiveRecord class to destroy) and a table string (the name of the table in the database), destroys the table and resets the primary key sequence.
94
- destroy_tables(class_names, table_strings): Given an array of class names (the names of the ActiveRecord classes to destroy) and an array of table strings (the names of the tables in the database), destroys all of the tables and resets their primary key sequences.
95
-
96
-
97
- # Common Issues:
98
-
99
- Deleting: The issue occurs if theres a directed graph cycle relation between tables, or if there are joins tables with multiple presence constraints on the foreign keys.
100
- Tip: To avoid this you have to typically drop the entire database, although this is obviously not recommended in production.
101
-
data/demo/db/.DS_Store DELETED
Binary file
data/demo/db/.gitignore DELETED
@@ -1 +0,0 @@
1
- /seed_files_unused/
@@ -1,16 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :users do |t|
4
- t.string :email, null: false
5
- t.string :username, null: false
6
- t.string :password_digest, null: false
7
- t.string :name, null:false
8
- t.string :phone_number, null:false, unique: true
9
- t.string :session_token, null: false
10
- t.timestamps
11
- end
12
- add_index :users, :email, unique: true
13
- add_index :users, :username, unique: true
14
- add_index :users, :session_token, unique: true
15
- end
16
- end
@@ -1,15 +0,0 @@
1
- class CreateRestaurants < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :restaurants do |t|
4
- t.string :name, null:false
5
- t.string :address, null:false, unique:true
6
- t.text :description, null:false
7
- t.string :state_code, null:false
8
- t.string :city, null:false
9
- t.float :rating, null:false
10
- t.float :longitude, null:false
11
- t.float :latitude, null:false
12
- t.timestamps
13
- end
14
- end
15
- end
@@ -1,9 +0,0 @@
1
- class CreateMenus < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :menus do |t|
4
- t.references :restaurant, null:false, unique:true, foreign_key: {to_table: :restaurants}
5
- t.timestamps
6
- end
7
- end
8
- end
9
-
@@ -1,11 +0,0 @@
1
- class CreateMenuItems < ActiveRecord::Migration[7.0]
2
- def change
3
-
4
- create_table :menu_items do |t|
5
- t.string :item_name, null:false
6
- t.float :price, null:false
7
- t.references :menu, null:false, index:true, foreign_key:{to_table: :menus}
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,57 +0,0 @@
1
- # This migration comes from active_storage (originally 20170806125915)
2
- class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
3
- def change
4
- # Use Active Record's configured type for primary and foreign keys
5
- primary_key_type, foreign_key_type = primary_and_foreign_key_types
6
-
7
- create_table :active_storage_blobs, id: primary_key_type do |t|
8
- t.string :key, null: false
9
- t.string :filename, null: false
10
- t.string :content_type
11
- t.text :metadata
12
- t.string :service_name, null: false
13
- t.bigint :byte_size, null: false
14
- t.string :checksum
15
-
16
- if connection.supports_datetime_with_precision?
17
- t.datetime :created_at, precision: 6, null: false
18
- else
19
- t.datetime :created_at, null: false
20
- end
21
-
22
- t.index [ :key ], unique: true
23
- end
24
-
25
- create_table :active_storage_attachments, id: primary_key_type do |t|
26
- t.string :name, null: false
27
- t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
28
- t.references :blob, null: false, type: foreign_key_type
29
-
30
- if connection.supports_datetime_with_precision?
31
- t.datetime :created_at, precision: 6, null: false
32
- else
33
- t.datetime :created_at, null: false
34
- end
35
-
36
- t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
37
- t.foreign_key :active_storage_blobs, column: :blob_id
38
- end
39
-
40
- create_table :active_storage_variant_records, id: primary_key_type do |t|
41
- t.belongs_to :blob, null: false, index: false, type: foreign_key_type
42
- t.string :variation_digest, null: false
43
-
44
- t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
45
- t.foreign_key :active_storage_blobs, column: :blob_id
46
- end
47
- end
48
-
49
- private
50
- def primary_and_foreign_key_types
51
- config = Rails.configuration.generators
52
- setting = config.options[config.orm][:primary_key_type]
53
- primary_key_type = setting || :primary_key
54
- foreign_key_type = setting || :bigint
55
- [primary_key_type, foreign_key_type]
56
- end
57
- end
@@ -1,10 +0,0 @@
1
- class CreateReviews < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :reviews do |t|
4
- t.text :body, null:false
5
- t.references :restaurant, null:false, index:true, foreign_key:{to_table: :restaurants}
6
- t.references :user, null:false, index:true, foreign_key:{to_table: :users}
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- class CreateCarts < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :carts do |t|
4
- t.references :menu_item, null:false, foreign_key:{to_table: :menu_items}
5
- t.references :user, null:false, foreign_key:{to_table: :users}
6
- t.integer :quantity, null:false
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- class CreateTransactions < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :transactions do |t|
4
- t.references :user, null:false, foreign_key:{to_table: :users}
5
- t.references :restaurant, null:false, foreign_key:{to_table: :restaurants}
6
- t.float :transaction_sum, null:false
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,5 +0,0 @@
1
- class EditRestaurants < ActiveRecord::Migration[7.0]
2
- def change
3
- add_column :restaurants, :cuisine_type, :string
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class EditRestaurantsDesc < ActiveRecord::Migration[7.0]
2
- def change
3
- remove_column :restaurants, :description
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddDesctoMenuItems < ActiveRecord::Migration[7.0]
2
- def change
3
- add_column :menu_items, :description, :string
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddHeaderToMenuItems < ActiveRecord::Migration[7.0]
2
- def change
3
- add_column :menu_items, :header, :string
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddFkCarts < ActiveRecord::Migration[7.0]
2
- def change
3
- add_reference :carts, :restaurant, null:false, foreign_key:{to_table: :restaurants}
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class EditTransaction < ActiveRecord::Migration[7.0]
2
- def change
3
- add_column :transactions, :review_left, :boolean
4
- end
5
- end
@@ -1,10 +0,0 @@
1
- class CreateLocations < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :locations do |t|
4
- t.references :user, null:false, foreign_key:{to_table: :users}, index:{unique: true}
5
- t.float :longitude, null:false
6
- t.float :latitude, null:false
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,5 +0,0 @@
1
- class DropCarts < ActiveRecord::Migration[7.0]
2
- def change
3
- drop_table :carts
4
- end
5
- end
@@ -1,9 +0,0 @@
1
- class CreateCarts2 < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :carts do |t|
4
- t.references :user, null:false, foreign_key:{to_table: :users}
5
- t.references :restaurant, null:false, foreign_key:{to_table: :restaurants}
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,10 +0,0 @@
1
- class CreateCartItems < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :cart_items do |t|
4
- t.references :menu_item, null:false, foreign_key:{to_table: :menu_items}
5
- t.references :cart, null:false, foreign_key:{to_table: :carts}
6
- t.integer :quantity, null:false
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,6 +0,0 @@
1
- class RemoveCartIndex < ActiveRecord::Migration[7.0]
2
- def change
3
- remove_index :carts, :restaurant_id
4
- remove_index :carts, :user_id
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- class EditCartsIndex < ActiveRecord::Migration[7.0]
2
- def change
3
- add_index :carts, [:user_id, :restaurant_id], unique: true
4
- end
5
- end
@@ -1,6 +0,0 @@
1
- class RemoveCartItemIndex < ActiveRecord::Migration[7.0]
2
- def change
3
- remove_index :cart_items, :cart_id
4
- remove_index :cart_items, :menu_item_id
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- class EditCartItemsIndex < ActiveRecord::Migration[7.0]
2
- def change
3
- add_index :cart_items, [:cart_id, :menu_item_id], unique:true
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class RemoveUsername < ActiveRecord::Migration[7.0]
2
- def change
3
- remove_column :users, :username
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddRestAvgPrice < ActiveRecord::Migration[7.0]
2
- def change
3
- add_column :restaurants, :avg_price, :integer
4
- end
5
- end
data/demo/db/schema.rb DELETED
@@ -1,149 +0,0 @@
1
- # This file is auto-generated from the current state of the database. Instead
2
- # of editing this file, please use the migrations feature of Active Record to
3
- # incrementally modify your database, and then regenerate this schema definition.
4
- #
5
- # This file is the source Rails uses to define your schema when running `bin/rails
6
- # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
- # be faster and is potentially less error prone than running all of your
8
- # migrations from scratch. Old migrations may fail to apply correctly if those
9
- # migrations use external dependencies or application code.
10
- #
11
- # It's strongly recommended that you check this file into your version control system.
12
-
13
- ActiveRecord::Schema[7.0].define(version: 2023_02_04_005331) do
14
- # These are extensions that must be enabled in order to support this database
15
- enable_extension "plpgsql"
16
-
17
- create_table "active_storage_attachments", force: :cascade do |t|
18
- t.string "name", null: false
19
- t.string "record_type", null: false
20
- t.bigint "record_id", null: false
21
- t.bigint "blob_id", null: false
22
- t.datetime "created_at", null: false
23
- t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
24
- t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
25
- end
26
-
27
- create_table "active_storage_blobs", force: :cascade do |t|
28
- t.string "key", null: false
29
- t.string "filename", null: false
30
- t.string "content_type"
31
- t.text "metadata"
32
- t.string "service_name", null: false
33
- t.bigint "byte_size", null: false
34
- t.string "checksum"
35
- t.datetime "created_at", null: false
36
- t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
37
- end
38
-
39
- create_table "active_storage_variant_records", force: :cascade do |t|
40
- t.bigint "blob_id", null: false
41
- t.string "variation_digest", null: false
42
- t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
43
- end
44
-
45
- create_table "cart_items", force: :cascade do |t|
46
- t.bigint "menu_item_id", null: false
47
- t.bigint "cart_id", null: false
48
- t.integer "quantity", null: false
49
- t.datetime "created_at", null: false
50
- t.datetime "updated_at", null: false
51
- t.index ["cart_id", "menu_item_id"], name: "index_cart_items_on_cart_id_and_menu_item_id", unique: true
52
- end
53
-
54
- create_table "carts", force: :cascade do |t|
55
- t.bigint "user_id", null: false
56
- t.bigint "restaurant_id", null: false
57
- t.datetime "created_at", null: false
58
- t.datetime "updated_at", null: false
59
- t.index ["user_id", "restaurant_id"], name: "index_carts_on_user_id_and_restaurant_id", unique: true
60
- end
61
-
62
- create_table "locations", force: :cascade do |t|
63
- t.bigint "user_id", null: false
64
- t.float "longitude", null: false
65
- t.float "latitude", null: false
66
- t.datetime "created_at", null: false
67
- t.datetime "updated_at", null: false
68
- t.index ["user_id"], name: "index_locations_on_user_id", unique: true
69
- end
70
-
71
- create_table "menu_items", force: :cascade do |t|
72
- t.string "item_name", null: false
73
- t.float "price", null: false
74
- t.bigint "menu_id", null: false
75
- t.datetime "created_at", null: false
76
- t.datetime "updated_at", null: false
77
- t.string "description"
78
- t.string "header"
79
- t.index ["menu_id"], name: "index_menu_items_on_menu_id"
80
- end
81
-
82
- create_table "menus", force: :cascade do |t|
83
- t.bigint "restaurant_id", null: false
84
- t.datetime "created_at", null: false
85
- t.datetime "updated_at", null: false
86
- t.index ["restaurant_id"], name: "index_menus_on_restaurant_id"
87
- end
88
-
89
- create_table "restaurants", force: :cascade do |t|
90
- t.string "name", null: false
91
- t.string "address", null: false
92
- t.string "state_code", null: false
93
- t.string "city", null: false
94
- t.float "rating", null: false
95
- t.float "longitude", null: false
96
- t.float "latitude", null: false
97
- t.datetime "created_at", null: false
98
- t.datetime "updated_at", null: false
99
- t.string "cuisine_type"
100
- t.integer "avg_price"
101
- end
102
-
103
- create_table "reviews", force: :cascade do |t|
104
- t.text "body", null: false
105
- t.bigint "restaurant_id", null: false
106
- t.bigint "user_id", null: false
107
- t.datetime "created_at", null: false
108
- t.datetime "updated_at", null: false
109
- t.index ["restaurant_id"], name: "index_reviews_on_restaurant_id"
110
- t.index ["user_id"], name: "index_reviews_on_user_id"
111
- end
112
-
113
- create_table "transactions", force: :cascade do |t|
114
- t.bigint "user_id", null: false
115
- t.bigint "restaurant_id", null: false
116
- t.float "transaction_sum", null: false
117
- t.datetime "created_at", null: false
118
- t.datetime "updated_at", null: false
119
- t.boolean "review_left"
120
- t.index ["restaurant_id"], name: "index_transactions_on_restaurant_id"
121
- t.index ["user_id"], name: "index_transactions_on_user_id"
122
- end
123
-
124
- create_table "users", force: :cascade do |t|
125
- t.string "email", null: false
126
- t.string "password_digest", null: false
127
- t.string "name", null: false
128
- t.string "phone_number", null: false
129
- t.string "session_token", null: false
130
- t.datetime "created_at", null: false
131
- t.datetime "updated_at", null: false
132
- t.index ["email"], name: "index_users_on_email", unique: true
133
- t.index ["session_token"], name: "index_users_on_session_token", unique: true
134
- end
135
-
136
- add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
137
- add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
138
- add_foreign_key "cart_items", "carts"
139
- add_foreign_key "cart_items", "menu_items"
140
- add_foreign_key "carts", "restaurants"
141
- add_foreign_key "carts", "users"
142
- add_foreign_key "locations", "users"
143
- add_foreign_key "menu_items", "menus"
144
- add_foreign_key "menus", "restaurants"
145
- add_foreign_key "reviews", "restaurants"
146
- add_foreign_key "reviews", "users"
147
- add_foreign_key "transactions", "restaurants"
148
- add_foreign_key "transactions", "users"
149
- end
@@ -1,6 +0,0 @@
1
- Email:string,Password:string,name:string,phone_number:string
2
- demo@user.io,password,Demo Lition,123-456-7890
3
- mfong415@gmail.com,password,Maxwell Fong,234-567-8901
4
- simpSupreme@gmail.com,password,Nishant Racherla,345-678-9821
5
- deez@nutz.com,password,Nestor Vega,415-255-5000
6
- kpatel@aa.io,password,Kush Patel,800-200-6000