Skip to content

Commit 9f8aadd

Browse files
committed
Merge branch 'main' of github.com:devforth/adminforth into next
AdminForth/1755/i-can't-write-to-this-input-wh
2 parents 94de01e + 33eeeab commit 9f8aadd

30 files changed

Lines changed: 1283 additions & 831 deletions

File tree

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,37 @@ Why AdminForth:
3737

3838
## Project initialisation
3939

40-
To create an AdminForth project, run:
40+
AdminForth supports two setup paths:
4141

42-
```bash
43-
npx adminforth create-app
44-
```
42+
### Path 1: Existing database
4543

46-
During the interactive initialization process, AdminForth will ask you to provide a local database URL.
44+
Use this path when you already have a database and your own schema or migrations. Provide your database URL with `--db`, or enter it when the CLI asks `Please specify the database URL to use`.
4745

48-
### Integrating AdminForth into your existing application
46+
```bash
47+
npx adminforth create-app --app-name myadmin --db "postgresql://user:password@localhost:5432/dbname"
48+
cd myadmin
49+
```
4950

50-
If you want to build an admin panel for an existing project that already has a database with tables, you can provide the connection URL to your existing development database, such as a local or deployed one.
51+
When you provide your own database URL, AdminForth connects to your database but does not create Prisma schema or migrations for it. The generated project README includes the SQL or schema notes needed to add the required `adminuser` table with your own migration tool.
5152

52-
After that, you may want to generate AdminForth resource files from your existing database tables:
53+
After project creation, generate AdminForth resource files from your existing tables:
5354

5455
```bash
5556
npx adminforth resource
5657
```
5758

58-
Resource files are needed for AdminForth to “know” about your tables and define how to work with them.
59+
### Path 2: New database
5960

60-
Use the command above every time you add new tables or change their schema.
61+
Use this path when you want AdminForth to scaffold a standalone app with a new local SQLite database. Omit `--db`, or accept the default `sqlite://.db.sqlite` value in the interactive prompt:
6162

62-
### Starting from scratch
63-
64-
If you do not have a database yet, start an empty local database, for example PostgreSQL in Docker, and provide its URL to the AdminForth CLI.
65-
66-
If the adminforth CLI does not detect any tables, it will suggest adding Prisma as a migration tool. Prisma is not related to AdminForth, but it is one of the most convenient migration tools.
63+
```bash
64+
npx adminforth create-app --app-name myadmin
65+
cd myadmin
66+
pnpm makemigration --name init && pnpm migrate:local
67+
pnpm dev
68+
```
6769

68-
Please follow [getting started](https://adminforth.dev/docs/tutorial/gettingStarted/).
70+
For the new database path, the CLI can scaffold Prisma files and migration scripts for the default `sqlite://.db.sqlite` database. Please follow [getting started](https://adminforth.dev/docs/tutorial/gettingStarted/) for the full guide.
6971

7072
# For AdminForth developers
7173

adminforth/commands/createApp/templates/readme.md.hbs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@ Install dependencies:
66
{{packageManager}} install
77
```
88

9-
Migrate the database:
9+
{{#if adminUserTableInstructions}}
10+
Prepare the admin users table in your existing database before starting the app. AdminForth uses this table for back-office authentication, and your own migration tool should own this schema change. The schema below is only an example:
11+
12+
{{{adminUserTableInstructions}}}
13+
14+
The generated app will seed the default `adminforth` / `adminforth` user on first start if the table is empty.
15+
{{/if}}
16+
17+
{{#if prismaDbUrl}}
18+
Create the initial migration and apply it to the database:
1019

1120
```bash
21+
{{packageManagerRun}} makemigration{{packageManagerScriptArgSeparator}}--name init
1222
{{packageManagerRun}} migrate:local
1323
```
24+
{{/if}}
1425

1526
Start the server:
1627

0 commit comments

Comments
 (0)