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
+27-21Lines changed: 27 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,44 +61,50 @@ npx adminforth create-app
61
61
62
62
The most convenient way to add new features or fixes is using `dev-demo`. It imports the source code of the repository and plugins so you can edit them and see changes on the fly.
63
63
64
-
Fork repo, pull it and do next:
64
+
To run dev demo:
65
+
```sh
66
+
cd dev-demo
65
67
68
+
npm run setup-dev-demo
69
+
npm run migrate:all
66
70
67
-
```sh
68
-
cd adminforth
69
-
npm ci
70
-
npm run build
71
+
npm start
71
72
```
72
73
73
-
To run dev demo:
74
-
```sh
75
-
cd dev-demo
76
-
cp .env.sample .env
74
+
## Adding columns to a database in dev-demo
77
75
78
-
# this will install all official plugins and link adminforth package, if plugin installed it will git pull and npm ci
79
-
npm run install-plugins
76
+
Open `./migrations` folder. There is prisma migration folder for the sqlite, postgres and mysql and `clickhouse_migrations` folder for the clickhouse:
80
77
81
-
# same for official adapters
82
-
npm run install-adapters
78
+
### Migrations for the MySQL, SQLite and Postgres
79
+
To make migration add to the .prisma file in folder with database you need and add new tables or columns. Then run:
83
80
84
-
npm ci
85
81
86
-
./run_inventory.sh
82
+
```
83
+
npm run makemigration:sqlite -- --name init
84
+
```
85
+
86
+
and
87
87
88
-
npm run migrate:local
89
-
npm start
88
+
```
89
+
npm run migrate:sqlite
90
90
```
91
91
92
-
## Adding columns to a database in dev-demo
92
+
to apply migration
93
+
94
+
> use :sqlite, :mysql or :postgres for you case
95
+
96
+
### Migrations for the clickhouse
93
97
94
-
Open `.prisma` file, modify it, and run:
98
+
In order to make migration for the clickhouse, go to the `./migrations/clickhouse_migrations` folder and add migration file to the folder.
95
99
100
+
Then run
96
101
```
97
-
npm run namemigration -- --name desctiption_of_changes
102
+
npm run migrate:clickhouse
98
103
```
99
104
105
+
to apply the migration.
100
106
101
-
###Testing CLI commands during development
107
+
## Testing CLI commands during development
102
108
103
109
104
110
Make sure you have not `adminforth` globally installed. If you have it, remove it:
> ☝️☝️☝️ This hooks should be written only inside column. If you'll add it in resource hooks - it won't work
214
+
207
215
In our case we limit the dropdown list to show only the current user, however you can use same sample to list only objects who are related to the current user in case if you will have relation configurations which require to show related objects which belongs to the current user.
Out of the box, AdminForth connects directly to your database using one of the supported drivers (PostgreSQL, MySQL, ClickHouse, MongoDB) and executes queries against it.
4
+
5
+
In some cases, you may not want to expose a direct database connection to AdminForth. Instead, you may prefer to allow AdminForth to access and modify data through your own APIs (for example, REST, GraphQL, or JSON-RPC).
6
+
7
+
With this approach, AdminForth never connects to the database and never even knows its URL. All read and write operations go through your API layer.
8
+
9
+
Why do this?
10
+
11
+
- Your API may enforce additional constraints or validation rules.
12
+
13
+
- You can precisely log all operations using your own logging or audit systems. (The built-in AuditLog tracks data modifications only and does not log read operations.)
14
+
15
+
- Your API may contain custom logic, such as distributed workflows or complex data-modification rules.
16
+
17
+
To implement this, you need to extend the data connector class and implement a small set of methods responsible for data access and mutations.
18
+
19
+
This example demonstrates how to do this using GraphQL, but the same approach can be adapted to REST or any other protocol. The code comments include detailed guidance for these cases.
20
+
21
+
Another reason to create a custom data source adapter is to support a database that AdminForth does not yet support. In that case, you are welcome to submit a pull request to AdminForth to add native support for that database.
0 commit comments