Your Next SaaS Template or Boilerplate ! A magic trip start with bun create saasfly
. The more stars, the more surprises
- Starting postgres
docker run -it --name postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres -e POSTGRES_DB=postgres -p 5432:5432 postgres:12
- Clone the repo
git clone https://github.com/saasfly/saasfly.git
cd saasfly
bun install
- Copy env file
cp .env.example .env.local
- Add database url to the env file and other env variables
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
-
Create pgcrypto extension in the database
-
Setup the database
bun db:push
- Run the app
bun run dev:web
- Create a new yugabyte cluster
docker run -d --name yugabyte -p 5433:5433 \
--hostname yugabyte -e YSQL_DB=yugabyte -e YSQL_USER=yugabyte -e YSQL_PASSWORD=yugabyte \
yugabytedb/yugabyte:2024.1.2.0-b77 \
bash -c 'rm -rf /tmp/.yb.* ; yugabyted start --enable_pg_parity_tech_preview --background=false --tserver_flags=ysql_colocate_database_by_default=true'
- Run offline migration
docker run -it --name ybv --link postgres:pg --link yugabyte:yb \
yugabytedb/yb-voyager:1.8.2 \
bash -c '
yb-voyager assess-migration --export-dir /var/tmp --start-clean=true --source-db-host pg --source-db-user postgres --source-db-password postgres --source-db-name postgres --source-db-schema public --source-db-type postgresql --iops-capture-interval 0
cat /var/tmp/assessment/reports/assessmentReport.json
yb-voyager export schema --export-dir /var/tmp --start-clean=true --source-db-host pg --source-db-user postgres --source-db-password postgres --source-db-name postgres --source-db-schema public --source-db-type postgresql
yb-voyager analyze-schema --export-dir /var/tmp
cat /var/tmp/reports/schema_analysis_report.txt
yb-voyager import schema --export-dir /var/tmp --target-db-host yb --target-db-user yugabyte --target-db-password yugabyte --target-db-name yugabyte --target-db-schema public
yb-voyager export data --export-dir /var/tmp --start-clean=true --source-db-host pg --source-db-user postgres --source-db-password postgres --source-db-name postgres --source-db-schema public --source-db-type postgresql
yb-voyager import data --export-dir /var/tmp --target-db-host yb --target-db-user yugabyte --target-db-password yugabyte --target-db-name yugabyte
'
- Change database url in the env file
DATABASE_URL="postgresql://yugabyte:yugabyte@localhost:5433/yugabyte"
- Run the app again
bun run dev:web
- App migrated successfully