Last active
August 13, 2021 18:09
-
-
Save iheanyi/5c71db921cbd4783840fed451af3e8d3 to your computer and use it in GitHub Desktop.
Code samples for "Building PlanetScale with PlanetScale"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/database.yml | |
development: | |
primary: | |
<<: *default | |
port: <%= ENV['ENABLE_PSDB'] ? 3305 : nil %> | |
database: <%= ENV['ENABLE_PSDB'] ? 'ourdatabase' : 'psdb_development' %> | |
primary_replica: | |
<<: *default | |
port: <%= ENV['ENABLE_PSDB'] ? 3305 : nil %> | |
database: <%= ENV['ENABLE_PSDB'] ? 'ourdatabase' : 'psdb_development' %> | |
replica: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/planetscale.rb | |
# Connect to the main production database and start the PlanetScale Proxy | |
if Rails.env.production? | |
PlanetScale.start( | |
org: 'planetscale', | |
db: 'ourdatabase', | |
branch: 'main' | |
) | |
elsif Rails.env.development? && ENV['ENABLE_PSDB'] | |
PlanetScale.start(org: 'planetscale') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment