introspective_grape 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +35 -0
  4. data/Gemfile +15 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +103 -0
  7. data/Rakefile +26 -0
  8. data/app/assets/images/introspective_grape/.keep +0 -0
  9. data/app/assets/stylesheets/introspective_grape/.keep +0 -0
  10. data/app/controllers/.keep +0 -0
  11. data/app/helpers/.keep +0 -0
  12. data/app/mailers/.keep +0 -0
  13. data/app/models/.keep +0 -0
  14. data/app/views/.keep +0 -0
  15. data/bin/rails +12 -0
  16. data/introspective_grape.gemspec +49 -0
  17. data/lib/introspective_grape/api.rb +445 -0
  18. data/lib/introspective_grape/camel_snake.rb +71 -0
  19. data/lib/introspective_grape/version.rb +3 -0
  20. data/lib/introspective_grape.rb +4 -0
  21. data/lib/tasks/introspective_grape_tasks.rake +4 -0
  22. data/spec/dummy/Gemfile +4 -0
  23. data/spec/dummy/README.rdoc +28 -0
  24. data/spec/dummy/Rakefile +6 -0
  25. data/spec/dummy/app/api/active_record_helpers.rb +17 -0
  26. data/spec/dummy/app/api/api_helpers.rb +36 -0
  27. data/spec/dummy/app/api/dummy/chat_api.rb +108 -0
  28. data/spec/dummy/app/api/dummy/company_api.rb +8 -0
  29. data/spec/dummy/app/api/dummy/entities.rb +25 -0
  30. data/spec/dummy/app/api/dummy/location_api.rb +37 -0
  31. data/spec/dummy/app/api/dummy/project_api.rb +51 -0
  32. data/spec/dummy/app/api/dummy/role_api.rb +7 -0
  33. data/spec/dummy/app/api/dummy/sessions.rb +55 -0
  34. data/spec/dummy/app/api/dummy/user_api.rb +32 -0
  35. data/spec/dummy/app/api/dummy_api.rb +57 -0
  36. data/spec/dummy/app/api/error_handlers.rb +28 -0
  37. data/spec/dummy/app/api/permissions_helper.rb +7 -0
  38. data/spec/dummy/app/assets/images/.keep +0 -0
  39. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  40. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  41. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  42. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  43. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  44. data/spec/dummy/app/mailers/.keep +0 -0
  45. data/spec/dummy/app/models/.keep +0 -0
  46. data/spec/dummy/app/models/abstract_adapter.rb +13 -0
  47. data/spec/dummy/app/models/admin_user.rb +6 -0
  48. data/spec/dummy/app/models/chat.rb +18 -0
  49. data/spec/dummy/app/models/chat_message.rb +34 -0
  50. data/spec/dummy/app/models/chat_message_user.rb +17 -0
  51. data/spec/dummy/app/models/chat_user.rb +16 -0
  52. data/spec/dummy/app/models/company.rb +14 -0
  53. data/spec/dummy/app/models/concerns/.keep +0 -0
  54. data/spec/dummy/app/models/image.rb +21 -0
  55. data/spec/dummy/app/models/job.rb +10 -0
  56. data/spec/dummy/app/models/locatable.rb +6 -0
  57. data/spec/dummy/app/models/location.rb +26 -0
  58. data/spec/dummy/app/models/location_beacon.rb +16 -0
  59. data/spec/dummy/app/models/location_gps.rb +14 -0
  60. data/spec/dummy/app/models/project.rb +20 -0
  61. data/spec/dummy/app/models/project_job.rb +7 -0
  62. data/spec/dummy/app/models/role.rb +30 -0
  63. data/spec/dummy/app/models/super_user.rb +11 -0
  64. data/spec/dummy/app/models/team.rb +9 -0
  65. data/spec/dummy/app/models/team_user.rb +13 -0
  66. data/spec/dummy/app/models/user/chatter.rb +79 -0
  67. data/spec/dummy/app/models/user.rb +84 -0
  68. data/spec/dummy/app/models/user_location.rb +28 -0
  69. data/spec/dummy/app/models/user_project_job.rb +16 -0
  70. data/spec/dummy/app/policies/application_policy.rb +47 -0
  71. data/spec/dummy/app/policies/chat_policy.rb +22 -0
  72. data/spec/dummy/app/policies/company_policy.rb +32 -0
  73. data/spec/dummy/app/policies/location_policy.rb +29 -0
  74. data/spec/dummy/app/policies/project_policy.rb +42 -0
  75. data/spec/dummy/app/policies/role_policy.rb +33 -0
  76. data/spec/dummy/app/policies/user_location_policy.rb +12 -0
  77. data/spec/dummy/app/policies/user_policy.rb +8 -0
  78. data/spec/dummy/app/views/layouts/application.html.erb +13 -0
  79. data/spec/dummy/bin/bundle +3 -0
  80. data/spec/dummy/bin/rails +4 -0
  81. data/spec/dummy/bin/rake +4 -0
  82. data/spec/dummy/bin/setup +29 -0
  83. data/spec/dummy/config/application.rb +38 -0
  84. data/spec/dummy/config/boot.rb +6 -0
  85. data/spec/dummy/config/database.yml +23 -0
  86. data/spec/dummy/config/environment.rb +11 -0
  87. data/spec/dummy/config/environments/development.rb +41 -0
  88. data/spec/dummy/config/environments/production.rb +79 -0
  89. data/spec/dummy/config/environments/test.rb +43 -0
  90. data/spec/dummy/config/initializers/assets.rb +11 -0
  91. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  92. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  93. data/spec/dummy/config/initializers/devise.rb +262 -0
  94. data/spec/dummy/config/initializers/devise_async.rb +2 -0
  95. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  96. data/spec/dummy/config/initializers/inflections.rb +16 -0
  97. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  98. data/spec/dummy/config/initializers/paperclip.rb +13 -0
  99. data/spec/dummy/config/initializers/paperclip_adapter.rb +13 -0
  100. data/spec/dummy/config/initializers/session_store.rb +3 -0
  101. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  102. data/spec/dummy/config/locales/devise.en.yml +60 -0
  103. data/spec/dummy/config/locales/en.yml +23 -0
  104. data/spec/dummy/config/routes.rb +8 -0
  105. data/spec/dummy/config/secrets.yml +22 -0
  106. data/spec/dummy/config.ru +4 -0
  107. data/spec/dummy/db/migrate/20141002205024_devise_create_users.rb +42 -0
  108. data/spec/dummy/db/migrate/20141002211055_devise_create_admin_users.rb +48 -0
  109. data/spec/dummy/db/migrate/20141002211057_create_active_admin_comments.rb +19 -0
  110. data/spec/dummy/db/migrate/20141002220722_add_lockable_to_users.rb +8 -0
  111. data/spec/dummy/db/migrate/20150406213646_create_companies.rb +11 -0
  112. data/spec/dummy/db/migrate/20150414213154_add_user_authentication_token.rb +11 -0
  113. data/spec/dummy/db/migrate/20150415222005_create_roles.rb +12 -0
  114. data/spec/dummy/db/migrate/20150505181635_create_chats.rb +9 -0
  115. data/spec/dummy/db/migrate/20150505181636_create_chat_users.rb +11 -0
  116. data/spec/dummy/db/migrate/20150505181640_create_chat_messages.rb +11 -0
  117. data/spec/dummy/db/migrate/20150507191529_create_chat_message_users.rb +11 -0
  118. data/spec/dummy/db/migrate/20150601200526_create_locations.rb +12 -0
  119. data/spec/dummy/db/migrate/20150601200533_create_locatables.rb +10 -0
  120. data/spec/dummy/db/migrate/20150601212924_create_location_beacons.rb +15 -0
  121. data/spec/dummy/db/migrate/20150601213542_create_location_gps.rb +12 -0
  122. data/spec/dummy/db/migrate/20150609201823_create_user_locations.rb +14 -0
  123. data/spec/dummy/db/migrate/20150616205336_add_role_user_constraint.rb +9 -0
  124. data/spec/dummy/db/migrate/20150617232519_create_projects.rb +10 -0
  125. data/spec/dummy/db/migrate/20150617232521_create_jobs.rb +9 -0
  126. data/spec/dummy/db/migrate/20150617232522_create_project_jobs.rb +11 -0
  127. data/spec/dummy/db/migrate/20150623170133_create_user_project_jobs.rb +12 -0
  128. data/spec/dummy/db/migrate/20150701234929_create_teams.rb +11 -0
  129. data/spec/dummy/db/migrate/20150701234930_create_team_users.rb +11 -0
  130. data/spec/dummy/db/migrate/20150727214950_add_confirmable_to_devise.rb +11 -0
  131. data/spec/dummy/db/migrate/20150820190524_add_user_names.rb +6 -0
  132. data/spec/dummy/db/migrate/20150824215701_create_images.rb +15 -0
  133. data/spec/dummy/db/migrate/20150909225019_add_password_to_project.rb +5 -0
  134. data/spec/dummy/db/schema.rb +278 -0
  135. data/spec/dummy/lib/assets/.keep +0 -0
  136. data/spec/dummy/log/.keep +0 -0
  137. data/spec/dummy/public/404.html +67 -0
  138. data/spec/dummy/public/422.html +67 -0
  139. data/spec/dummy/public/500.html +66 -0
  140. data/spec/dummy/public/favicon.ico +0 -0
  141. data/spec/fixtures/images/avatar.jpeg +0 -0
  142. data/spec/fixtures/images/exif.jpeg +0 -0
  143. data/spec/models/chat_spec.rb +32 -0
  144. data/spec/models/image_spec.rb +14 -0
  145. data/spec/models/locatable_spec.rb +10 -0
  146. data/spec/models/project_spec.rb +17 -0
  147. data/spec/models/role_spec.rb +63 -0
  148. data/spec/models/team_spec.rb +17 -0
  149. data/spec/models/team_user_spec.rb +20 -0
  150. data/spec/models/user_location_spec.rb +35 -0
  151. data/spec/models/user_project_job_spec.rb +30 -0
  152. data/spec/models/user_spec.rb +125 -0
  153. data/spec/rails_helper.rb +23 -0
  154. data/spec/requests/chat_api_spec.rb +174 -0
  155. data/spec/requests/company_api_spec.rb +61 -0
  156. data/spec/requests/location_api_spec.rb +96 -0
  157. data/spec/requests/project_api_spec.rb +151 -0
  158. data/spec/requests/role_api_spec.rb +37 -0
  159. data/spec/requests/sessions_api_spec.rb +55 -0
  160. data/spec/requests/user_api_spec.rb +191 -0
  161. data/spec/support/blueprints.rb +103 -0
  162. data/spec/support/location_helper.rb +56 -0
  163. data/spec/support/pundit_helpers.rb +13 -0
  164. data/spec/support/request_helpers.rb +22 -0
  165. metadata +562 -0
@@ -0,0 +1,60 @@
1
+ # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
+
3
+ en:
4
+ devise:
5
+ confirmations:
6
+ confirmed: "Your email address has been successfully confirmed."
7
+ send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9
+ failure:
10
+ already_authenticated: "You are already signed in."
11
+ inactive: "Your account is not activated yet."
12
+ invalid: "Invalid %{authentication_keys} or password."
13
+ locked: "Your account is locked."
14
+ last_attempt: "You have one more attempt before your account is locked."
15
+ not_found_in_database: "Invalid %{authentication_keys} or password."
16
+ timeout: "Your session expired. Please sign in again to continue."
17
+ unauthenticated: "You need to sign in or sign up before continuing."
18
+ unconfirmed: "You have to confirm your email address before continuing."
19
+ mailer:
20
+ confirmation_instructions:
21
+ subject: "Confirmation instructions"
22
+ reset_password_instructions:
23
+ subject: "Reset password instructions"
24
+ unlock_instructions:
25
+ subject: "Unlock instructions"
26
+ omniauth_callbacks:
27
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
28
+ success: "Successfully authenticated from %{kind} account."
29
+ passwords:
30
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
31
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
32
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
33
+ updated: "Your password has been changed successfully. You are now signed in."
34
+ updated_not_active: "Your password has been changed successfully."
35
+ registrations:
36
+ destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
37
+ signed_up: "Welcome! You have signed up successfully."
38
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
39
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
40
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
41
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
42
+ updated: "Your account has been updated successfully."
43
+ sessions:
44
+ signed_in: "Signed in successfully."
45
+ signed_out: "Signed out successfully."
46
+ already_signed_out: "Signed out successfully."
47
+ unlocks:
48
+ send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
49
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
50
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
51
+ errors:
52
+ messages:
53
+ already_confirmed: "was already confirmed, please try signing in"
54
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
55
+ expired: "has expired, please request a new one"
56
+ not_found: "not found"
57
+ not_locked: "was not locked"
58
+ not_saved:
59
+ one: "1 error prohibited this %{resource} from being saved:"
60
+ other: "%{count} errors prohibited this %{resource} from being saved:"
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,8 @@
1
+ Rails.application.routes.draw do
2
+ devise_for :users
3
+
4
+ # You can have the root of your site routed with "root"
5
+ root 'home#index'
6
+
7
+ mount DummyAPI => '/api'
8
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: ca9d4587a556cfc28464dcf7f9d73b396e53b814cd339a469bc817011485510d3a9d1d6a7fa08f65cce65bcd55727a7110de0077a952f50ce58a956b255c6903
15
+
16
+ test:
17
+ secret_key_base: ca9d4587a556cfc28464dcf7f9d73b396e53b814cd339a469bc817011485510d3a9d1d6a7fa08f65cce65bcd55727a7110de0077a952f50ce58a956b255c6903
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,42 @@
1
+ class DeviseCreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table(:users) do |t|
4
+ ## Database authenticatable
5
+ t.string :email, null: false, default: ""
6
+ t.string :encrypted_password, null: false, default: ""
7
+
8
+ ## Recoverable
9
+ t.string :reset_password_token
10
+ t.datetime :reset_password_sent_at
11
+
12
+ ## Rememberable
13
+ t.datetime :remember_created_at
14
+
15
+ ## Trackable
16
+ t.integer :sign_in_count, default: 0, null: false
17
+ t.datetime :current_sign_in_at
18
+ t.datetime :last_sign_in_at
19
+ t.inet :current_sign_in_ip
20
+ t.inet :last_sign_in_ip
21
+
22
+ ## Confirmable
23
+ # t.string :confirmation_token
24
+ # t.datetime :confirmed_at
25
+ # t.datetime :confirmation_sent_at
26
+ # t.string :unconfirmed_email # Only if using reconfirmable
27
+
28
+ ## Lockable
29
+ # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
30
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
31
+ # t.datetime :locked_at
32
+
33
+
34
+ t.timestamps null: false
35
+ end
36
+
37
+ add_index :users, :email, unique: true
38
+ add_index :users, :reset_password_token, unique: true
39
+ # add_index :users, :confirmation_token, unique: true
40
+ # add_index :users, :unlock_token, unique: true
41
+ end
42
+ end
@@ -0,0 +1,48 @@
1
+ class DeviseCreateAdminUsers < ActiveRecord::Migration
2
+ def migrate(direction)
3
+ super
4
+ # Create a default user
5
+ AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if direction == :up
6
+ end
7
+
8
+ def change
9
+ create_table(:admin_users) do |t|
10
+ ## Database authenticatable
11
+ t.string :email, null: false, default: ""
12
+ t.string :encrypted_password, null: false, default: ""
13
+
14
+ ## Recoverable
15
+ t.string :reset_password_token
16
+ t.datetime :reset_password_sent_at
17
+
18
+ ## Rememberable
19
+ t.datetime :remember_created_at
20
+
21
+ ## Trackable
22
+ t.integer :sign_in_count, default: 0, null: false
23
+ t.datetime :current_sign_in_at
24
+ t.datetime :last_sign_in_at
25
+ t.inet :current_sign_in_ip
26
+ t.inet :last_sign_in_ip
27
+
28
+ ## Confirmable
29
+ # t.string :confirmation_token
30
+ # t.datetime :confirmed_at
31
+ # t.datetime :confirmation_sent_at
32
+ # t.string :unconfirmed_email # Only if using reconfirmable
33
+
34
+ ## Lockable
35
+ # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
36
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
37
+ # t.datetime :locked_at
38
+
39
+
40
+ t.timestamps null: false
41
+ end
42
+
43
+ add_index :admin_users, :email, unique: true
44
+ add_index :admin_users, :reset_password_token, unique: true
45
+ # add_index :admin_users, :confirmation_token, unique: true
46
+ # add_index :admin_users, :unlock_token, unique: true
47
+ end
48
+ end
@@ -0,0 +1,19 @@
1
+ class CreateActiveAdminComments < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :active_admin_comments do |t|
4
+ t.string :namespace
5
+ t.text :body
6
+ t.string :resource_id, null: false, foreign_key: false
7
+ t.string :resource_type, null: false
8
+ t.references :author, polymorphic: true
9
+ t.timestamps null: false
10
+ end
11
+ add_index :active_admin_comments, [:namespace]
12
+ add_index :active_admin_comments, [:author_type, :author_id]
13
+ add_index :active_admin_comments, [:resource_type, :resource_id]
14
+ end
15
+
16
+ def self.down
17
+ drop_table :active_admin_comments
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ class AddLockableToUsers < ActiveRecord::Migration
2
+ def change
3
+ # add Lockable columns
4
+ add_column :users, :failed_attempts, :integer, default: 0, null: false
5
+ add_column :users, :unlock_token, :string
6
+ add_column :users, :locked_at, :datetime
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ class CreateCompanies < ActiveRecord::Migration
2
+ def change
3
+ create_table :companies do |t|
4
+ t.string :name, limit: 256, null: false
5
+ t.string :short_name, limit: 10, null: false
6
+
7
+ t.timestamps null: false
8
+ end
9
+ add_index :companies, :name, unique: true
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class AddUserAuthenticationToken < ActiveRecord::Migration
2
+ def change
3
+ add_column :users, :authentication_token, :string
4
+ add_index :users, :authentication_token, :unique => true
5
+ end
6
+
7
+ def down
8
+ remove_index :users, :authentication_token
9
+ remove_column :users, :authentication_token
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class CreateRoles < ActiveRecord::Migration
2
+ def change
3
+ create_table :roles do |t|
4
+ t.integer :user_id
5
+ t.references :ownable, polymorphic: true, index: true
6
+
7
+ t.timestamps null: false
8
+ end
9
+ add_index :roles, [:user_id,:ownable_type,:ownable_id], unique: true
10
+ end
11
+
12
+ end
@@ -0,0 +1,9 @@
1
+ class CreateChats < ActiveRecord::Migration
2
+ def change
3
+ create_table :chats do |t|
4
+ t.integer :creator_id, references: :users, foreign_key: false
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class CreateChatUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :chat_users do |t|
4
+ t.references :chat, chat: true, index: true, foreign_key: true
5
+ t.references :user, index: true, foreign_key: false
6
+ t.datetime :departed_at
7
+
8
+ t.timestamps null: false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateChatMessages < ActiveRecord::Migration
2
+ def change
3
+ create_table :chat_messages do |t|
4
+ t.references :chat, chat: true, index: true, foreign_key: true
5
+ t.integer :author_id, references: :users, index: true, foreign_key: false
6
+ t.text :message
7
+
8
+ t.timestamps null: false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateChatMessageUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :chat_message_users do |t|
4
+ t.references :chat_message, index: true, foreign_key: true
5
+ t.references :user, index: true, foreign_key: false
6
+ t.timestamp :read_at
7
+
8
+ t.timestamps null: false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class CreateLocations < ActiveRecord::Migration
2
+ def change
3
+ create_table :locations do |t|
4
+ t.string :name, null: false
5
+ t.string :kind
6
+ t.integer :parent_location_id, index: true, foreign_key: false
7
+
8
+ t.timestamps null: false
9
+ end
10
+ add_index :locations, [:parent_location_id,:kind,:name], unique: true
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ class CreateLocatables < ActiveRecord::Migration
2
+ def change
3
+ create_table :locatables do |t|
4
+ t.references :location
5
+ t.references :locatable, polymorphic: true, index: true
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ class CreateLocationBeacons < ActiveRecord::Migration
2
+ def change
3
+ create_table :location_beacons do |t|
4
+ t.references :location
5
+ t.references :company, null: false
6
+ t.string :mac_address, limit: 12
7
+ t.string :uuid, null: false, limit: 32
8
+ t.integer :major, null: false
9
+ t.integer :minor, null: false
10
+
11
+ t.timestamps null: false
12
+ end
13
+ add_index :location_beacons, [:company_id,:uuid,:major,:minor], name: "index_location_beacons_unique_company_identifier", unique: true
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ class CreateLocationGps < ActiveRecord::Migration
2
+ def change
3
+ create_table :location_gps do |t|
4
+ t.references :location, index: true, foreign_key: true
5
+ t.float :lat, null: false
6
+ t.float :lng, null: false
7
+ t.float :alt, default: 0
8
+
9
+ t.timestamps null: false
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ class CreateUserLocations < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_locations do |t|
4
+ t.references :user, index: true, foreign_key: true
5
+ t.references :location, index: true, foreign_key: true
6
+ t.references :detectable, polymorphic: true, index: true
7
+ t.float :lat
8
+ t.float :lng
9
+ t.float :alt
10
+
11
+ t.timestamps null: false
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class AddRoleUserConstraint < ActiveRecord::Migration
2
+ def up
3
+ change_column :roles, :user_id, :integer, null: false
4
+ end
5
+
6
+ def down
7
+ change_column :roles, :user_id, :integer, null: true
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ class CreateProjects < ActiveRecord::Migration
2
+ def change
3
+ create_table :projects do |t|
4
+ t.string :name, null: false
5
+ t.integer :owner_id, references: :companies, index: true, foreign_key: true
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ class CreateJobs < ActiveRecord::Migration
2
+ def change
3
+ create_table :jobs do |t|
4
+ t.string :title, null: false
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class CreateProjectJobs < ActiveRecord::Migration
2
+ def change
3
+ create_table :project_jobs do |t|
4
+ t.references :project, index: true, null: false, foreign_key: true
5
+ t.references :job, index: true, null: false, foreign_key: true
6
+
7
+ t.timestamps null: false
8
+ end
9
+ add_index :project_jobs, [:project_id,:job_id], unique: true
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class CreateUserProjectJobs < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_project_jobs do |t|
4
+ t.references :user, index: true, foreign_key: true, null: false
5
+ t.references :project, index: true, foreign_key: true, null: false
6
+ t.references :job, index: true, foreign_key: true, null: false
7
+
8
+ t.timestamps null: false
9
+ end
10
+ add_index :user_project_jobs, [:user_id,:project_id,:job_id], unique: true
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ class CreateTeams < ActiveRecord::Migration
2
+ def change
3
+ create_table :teams do |t|
4
+ t.string :name
5
+ t.references :project, index: true, foreign_key: true
6
+ t.references :creator, references: :users, index: true, foreign_key: true
7
+
8
+ t.timestamps null: false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateTeamUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :team_users do |t|
4
+ t.references :user, index: true, foreign_key: true
5
+ t.references :team, index: true, foreign_key: true
6
+
7
+ t.timestamps null: false
8
+ end
9
+ add_index :team_users, [:user_id,:team_id], unique: true
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class AddConfirmableToDevise < ActiveRecord::Migration
2
+ def change
3
+ change_table(:users) do |t|
4
+ t.string :confirmation_token
5
+ t.datetime :confirmed_at
6
+ t.datetime :confirmation_sent_at
7
+ t.string :unconfirmed_email
8
+ end
9
+ add_index :users, :confirmation_token, unique: true
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ class AddUserNames < ActiveRecord::Migration
2
+ def change
3
+ add_column :users, :first_name, :string
4
+ add_column :users, :last_name, :string
5
+ end
6
+ end
@@ -0,0 +1,15 @@
1
+ class CreateImages < ActiveRecord::Migration
2
+ def change
3
+ create_table :images do |t|
4
+ t.references :imageable, polymorphic: true, index: true
5
+ t.attachment :file
6
+ t.boolean :file_processing, null: false, default: false
7
+ t.json :meta
8
+ t.string :source
9
+ t.float :lat
10
+ t.float :lng
11
+ t.timestamp :taken_at
12
+ t.timestamps null: false
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ class AddPasswordToProject < ActiveRecord::Migration
2
+ def change
3
+ add_column :projects, :default_password, :string
4
+ end
5
+ end