Skip to content

Instantly share code, notes, and snippets.

@iheanyi
Last active August 13, 2021 18:09
Show Gist options
  • Save iheanyi/5c71db921cbd4783840fed451af3e8d3 to your computer and use it in GitHub Desktop.
Save iheanyi/5c71db921cbd4783840fed451af3e8d3 to your computer and use it in GitHub Desktop.
Code samples for "Building PlanetScale with PlanetScale"
# 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
# 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