

ON verification_requests ( token ) Connect database and enable email provider in next-auth ON users ( email ) CREATE UNIQUE INDEX token

ON sessions ( access_token ) CREATE UNIQUE INDEX email ON sessions ( session_token ) CREATE UNIQUE INDEX access_token ON accounts ( user_id ) CREATE UNIQUE INDEX session_token ON accounts ( provider_id ) CREATE INDEX user_id ON accounts ( provider_account_id ) CREATE INDEX provider_id ON accounts ( compound_id ) CREATE INDEX provider_account_id I use Postgres.app for Postgres on localhost, and often start with a Heroku Postgres DB on the Hobby plan for the deployed version of small projects like this.Ĭonnect to your database using psql or a client like Postico.ĬREATE TABLE accounts ( id SERIAL, compound_id VARCHAR ( 255 ) NOT NULL, user_id INTEGER NOT NULL, provider_type VARCHAR ( 255 ) NOT NULL, provider_id VARCHAR ( 255 ) NOT NULL, provider_account_id VARCHAR ( 255 ) NOT NULL, refresh_token TEXT, access_token TEXT, access_token_expires TIMESTAMPTZ, created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY ( id ) ) CREATE TABLE sessions ( id SERIAL, user_id INTEGER NOT NULL, expires TIMESTAMPTZ NOT NULL, session_token VARCHAR ( 255 ) NOT NULL, access_token VARCHAR ( 255 ) NOT NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY ( id ) ) CREATE TABLE users ( id SERIAL, name VARCHAR ( 255 ), email VARCHAR ( 255 ), email_verified TIMESTAMPTZ, image TEXT, created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY ( id ) ) CREATE TABLE verification_requests ( id SERIAL, identifier VARCHAR ( 255 ) NOT NULL, token VARCHAR ( 255 ) NOT NULL, expires TIMESTAMPTZ NOT NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY ( id ) ) CREATE UNIQUE INDEX compound_id PostgresSQL is our default relational DB choice at Echobind, so that’s what we’ll use for this example. Create and structure a databaseĭatabase integration is required for email auth in next-auth currently, so we need to get this running first.įirst we need a database. GitHub - PhinCo/heroku-postico: Tools to make it easier to connect to Heroku postgres databases from Postico. Source can be found in this branch at GitHub. Tools to make it easier to connect to Heroku postgres databases from Postico.
#Connecting to postico heroku how to#
Another way many apps like to allow people to sign in easily is via use of a “magic link.” The user will enter their email address and receive an email with a link they can click to login to the app.Īs you may have guessed, that’s pretty easy with next-auth too 😉 Here’s how to do it. Check out the first article for background: One-Click Signup in Next.js With next-auth)įrom our previous article in this series, we know that one-click signup / sign in with next-auth using Google, GitHub, Facebook, or any other provider is pretty easy. How can I connect to Postgres running in a Docker container on a.
#Connecting to postico heroku code#
(This is the second article in a series on next-auth. Implement Postico with how-to, Q&A, fixes, code snippets.
