You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-16Lines changed: 18 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,35 +37,37 @@ Why AdminForth:
37
37
38
38
## Project initialisation
39
39
40
-
To create an AdminForth project, run:
40
+
AdminForth supports two setup paths:
41
41
42
-
```bash
43
-
npx adminforth create-app
44
-
```
42
+
### Path 1: Existing database
45
43
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`.
47
45
48
-
### Integrating AdminForth into your existing application
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.
51
52
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:
53
54
54
55
```bash
55
56
npx adminforth resource
56
57
```
57
58
58
-
Resource files are needed for AdminForth to “know” about your tables and define how to work with them.
59
+
### Path 2: New database
59
60
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:
61
62
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.
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.
Copy file name to clipboardExpand all lines: adminforth/commands/createApp/templates/readme.md.hbs
+12-1Lines changed: 12 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,22 @@ Install dependencies:
6
6
{{packageManager}} install
7
7
```
8
8
9
-
Migrate the database:
9
+
{{#ifadminUserTableInstructions}}
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
+
{{#ifprismaDbUrl}}
18
+
Create the initial migration and apply it to the database:
0 commit comments