System Information
- Strapi Version: v3.3.4
- Operating System: MacOS Big Sur
- Database: PostgreSQL
- Node Version: v14.15.1
- NPM Version: v6.14.8
- Yarn Version: N/A
When installing the strapi blog template locally according to the most recent documentation everything works great. I can configure Heroku with a PostgreSQL database and I can add content types locally which get reflected on the production build… but if I add content (like a new Category or Article) to the local server, it isn’t reflected on the production build. I tried to point the local development server at the PostgreSQL db by mirroring the ./config/env/production/database.js
in ./config/database.js
but I end up with this error:
Could not load js config file config/database.js: Cannot read property ' charAt' of undefined
I’m new to strapi, so I don’t fully understand how data is stored, but it seems like content-types are stored in the build itself, while content is stored in the database (SQLite locally and PostgreSQL in production), and that is where the discrepancy lies.
So the question/issue: Is there a way to a.) get the content to be in sync locally and in production, and b.) do it without producing that error above? This isn’t critical obviously as the application can still fully function if I just revert to using sqlite for local development, but it feels off to me that I would be creating a CMS that has out-of-sync content depending on where I am editing things (Heroku v local).
Code Snippets:
./config/database.js
:
module.exports = ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'sqlite',
filename: env('DATABASE_FILENAME', '.tmp/data.db'),
},
options: {
useNullAsDefault: true,
},
},
},
});
./config/env/production/database.js
:
const parse = require('pg-connection-string').parse;
const config = parse(process.env.DATABASE_URL);
module.exports = ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'postgres',
host: config.host,
port: config.port,
database: config.database,
username: config.user,
password: config.password,
},
options: {
ssl: false,
},
},
},
});