This guide will help you set up the project locally.
Ensure you have the following installed on your machine:
- Node.js (v16 or higher)
- Yarn (v1.22.22 or higher)
- Docker
-
Clone the repository:
git clone <repository-url>
-
Install dependencies:
yarn install
-
Set up environment variables:
-
Copy the
.env.examplefile to.env: -
Update the
.envfile with your specific values if necessary.
-
-
Start the PostgreSQL database using Docker:
docker-compose up -d
-
Run the development server:
yarn dev
-
Build the project:
yarn build
-
Start the production server:
yarn start
-
Lint the project:
yarn lint
This project uses Payload's migrate CLI wired to the Postgres adapter. Migration files live in ./src/migrations and are indexed by ./src/migrations/index.ts.
Common tasks:
-
Create a new migration (auto-generates a timestamped file):
yarn migrate:create <name> # example yarn migrate:create add_regulations_file_eng
Options:
--skip-emptyto avoid creating an empty migration when nothing changed
-
Apply pending migrations (up):
yarn migrate
-
Show migration status:
yarn migrate:status
-
Roll back the last batch:
yarn migrate:down
-
Reset/refresh (use with care):
yarn migrate:reset # run all downs yarn migrate:refresh # run downs then ups yarn migrate:fresh # drops DB and runs ups (requires --yes already in script)
Typical workflow:
- Modify your Payload collections/config.
- Generate a migration:
yarn migrate:create meaningful_name. - Review the generated file in
src/migrations/(it uses Postgres SQL viadb.execute(sql\...`)`). - Run
yarn migrateto apply.
Notes:
- The CLI auto-updates
src/migrations/index.ts. Avoid manual edits unless you know what you're doing. - Ensure database env vars (e.g.,
DATABASE_URL) are set. Formigrate:create, Payload initializes without DB connect; for running migrations, DB must be reachable. - Scripts are available in
package.jsonunderscripts.
- Ensure Docker is running before starting the development server.
- The database connection string and other secrets are managed in the
.envfile. - The project uses Tailwind CSS for styling and Payload CMS for content management.