Skip to content

Commit

Permalink
Add app id seed (#82)
Browse files Browse the repository at this point in the history
* add test track app and app_id identifier type to seeds

* add missing newline

* add migration for idempotently inserting test_track app and app_id identifier type

* add space for readability
  • Loading branch information
effron authored and samandmoore committed Aug 1, 2018
1 parent 75476ce commit feb09b5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
14 changes: 14 additions & 0 deletions db/migrate/20180801150624_add_test_track_app_and_app_id.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class AddTestTrackAppAndAppId < ActiveRecord::Migration[5.0]
class App < ActiveRecord::Base; end
class IdentifierType < ActiveRecord::Base; end

def up
test_track_app = App.find_or_create_by!(name: 'TestTrack') do |app|
app.auth_secret = SecureRandom.urlsafe_base64(32)
end

IdentifierType.find_or_create_by!(name: 'app_id') do |identifier_type|
identifier_type.owner_app_id = test_track_app.id
end
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180412153251) do
ActiveRecord::Schema.define(version: 20180801150624) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down
8 changes: 8 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@
end
end
end

test_track_app = App.find_or_create_by!(name: 'TestTrack') do |app|
app.auth_secret = SecureRandom.urlsafe_base64(32)
end

IdentifierType.find_or_create_by!(name: 'app_id') do |identifier_type|
identifier_type.owner_app = test_track_app
end

0 comments on commit feb09b5

Please sign in to comment.