Skip to content

Commit 784ee49

Browse files
committed
chore: add clickhouse to the dev demo
1 parent 35db5bc commit 784ee49

File tree

26 files changed

+108
-18
lines changed

26 files changed

+108
-18
lines changed

dev-demo/.env.local

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
ADMINFORTH_SECRET=123
22
NODE_ENV=development
3-
SQLITE_URL=sqlite://prisma/sqlite/.db.sqlite
3+
SQLITE_URL=sqlite://migrations/prisma/sqlite/.db.sqlite
44
SQLITE_FILE_URL=file:.db.sqlite
55

6+
CH_MIGRATIONS_HOME=./migrations/clickhouse_migrations
7+
CH_MIGRATIONS_HOST=localhost:8124/demo
8+
CH_MIGRATIONS_USER=demo
9+
CH_MIGRATIONS_PASSWORD=demo
10+
611
AWS_REGION=eu-central-1
712
AWS_BUCKET_NAME=tmpbucket-adminforth

dev-demo/index.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const admin = new AdminForth({
106106
cars_MyS_resource,
107107
cars_PG_resource,
108108
cars_Mongo_resource,
109-
//cars_Ch_resource,
109+
cars_Ch_resource,
110110
passkeysResource,
111111
carsDescriptionImage,
112112
translations,
@@ -144,10 +144,10 @@ export const admin = new AdminForth({
144144
label: 'Cars (MongoDB)',
145145
resourceId: 'cars_mongo',
146146
},
147-
// {
148-
// label: 'Cars (ClickHouse)',
149-
// resourceId: 'cars_ch',
150-
// }
147+
{
148+
label: 'Cars (ClickHouse)',
149+
resourceId: 'cars_ch',
150+
}
151151
],
152152
},
153153
{
@@ -262,6 +262,23 @@ if (fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) {
262262
});
263263
};
264264
}
265+
266+
if (await admin.resource('cars_ch').count() === 0) {
267+
for (let i = 0; i < 100; i++) {
268+
const engine_type = ENGINE_TYPES[Math.floor(Math.random() * ENGINE_TYPES.length)].value;
269+
await admin.resource('cars_ch').create({
270+
id: `${i}`,
271+
model: `${FICTIONAL_CAR_BRANDS[Math.floor(Math.random() * FICTIONAL_CAR_BRANDS.length)]} ${FICTIONAL_CAR_MODELS_BY_BRAND[FICTIONAL_CAR_BRANDS[Math.floor(Math.random() * FICTIONAL_CAR_BRANDS.length)]][Math.floor(Math.random() * 4)]}`,
272+
price: (Math.random() * 10000).toFixed(2),
273+
engine_type: engine_type,
274+
engine_power: engine_type === 'electric' ? null : Math.floor(Math.random() * 400) + 100,
275+
production_year: Math.floor(Math.random() * 31) + 1990,
276+
listed: i % 2 == 0,
277+
mileage: `${Math.floor(Math.random() * 200000)}`,
278+
body_type: BODY_TYPES[Math.floor(Math.random() * BODY_TYPES.length)].value,
279+
});
280+
};
281+
}
265282
});
266283

267284
admin.express.listen(port, () => {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
CREATE TABLE IF NOT EXISTS cars (
2+
id String,
3+
4+
model String,
5+
price Float64,
6+
7+
created_at DateTime DEFAULT now(),
8+
9+
engine_type Nullable(String),
10+
engine_power Nullable(Int32),
11+
production_year Nullable(Int32),
12+
13+
description Nullable(String),
14+
listed Bool DEFAULT false,
15+
16+
mileage Nullable(Float64),
17+
color Nullable(String),
18+
body_type Nullable(String),
19+
20+
photos Nullable(String),
21+
22+
seller_id Nullable(String),
23+
seller Nullable(String),
24+
25+
promo_picture Nullable(String),
26+
generated_promo_picture Nullable(String)
27+
)
28+
29+
ENGINE = MergeTree
30+
ORDER BY tuple();

dev-demo/prisma/mysql/migrations/20260102133304_test/migration.sql renamed to dev-demo/migrations/prisma/mysql/migrations/20260102133304_test/migration.sql

File renamed without changes.

dev-demo/prisma/mysql/migrations/migration_lock.toml renamed to dev-demo/migrations/prisma/mysql/migrations/migration_lock.toml

File renamed without changes.
File renamed without changes.
File renamed without changes.

dev-demo/prisma/postgres/migrations/20260102130830_test/migration.sql renamed to dev-demo/migrations/prisma/postgres/migrations/20260102130830_test/migration.sql

File renamed without changes.

dev-demo/prisma/postgres/migrations/migration_lock.toml renamed to dev-demo/migrations/prisma/postgres/migrations/migration_lock.toml

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)