Skip to content

Commit 32ce30b

Browse files
authored
feat: replace mysql with sqlite (#393)
1 parent c580852 commit 32ce30b

38 files changed

+631
-1854
lines changed

docker-compose.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,6 @@ services:
88
- 6379:6379
99
restart: unless-stopped
1010

11-
mysql:
12-
image: mariadb:12.2.2
13-
environment:
14-
MYSQL_RANDOM_ROOT_PASSWORD: true
15-
MYSQL_DATABASE: lagoss
16-
MYSQL_USER: lagoss
17-
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
18-
ports:
19-
- 3306:3306
20-
volumes:
21-
- mysql:/var/lib/mysql
22-
restart: unless-stopped
23-
2411
prometheus:
2512
image: prom/prometheus:v3.9.1
2613
ports:
@@ -70,7 +57,6 @@ services:
7057

7158
volumes:
7259
valkey:
73-
mysql:
7460
prometheus:
7561
grafana:
7662
clickhouse:

packages/dashboard/.env.example

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
NEXTAUTH_URL=http://localhost:3000
2-
NEXTAUTH_SECRET=
3-
41
REDIS_URL=redis://localhost:6379
5-
DATABASE_URL=mysql://root:mysql@localhost:3306/lagoss
2+
NUXT_DATABASE_URL=file:.data/lagoss.sqlite
63
LAGOSS_RESTRICT_LOGIN=false
74
LAGOSS_BLACKLISTED_FUNCTIONS_NAMES=
85
LAGOSS_ROOT_SCHEM=http
@@ -17,23 +14,10 @@ S3_SECRET_ACCESS_KEY=supersecret
1714

1815
GITHUB_CLIENT_ID=
1916
GITHUB_CLIENT_SECRET=
20-
GOOGLE_CLIENT_ID=
21-
GOOGLE_CLIENT_SECRET=
2217

2318
AXIOM_ORG_ID=
2419
AXIOM_TOKEN=
2520

2621
CLICKHOUSE_URL=http://localhost:8123
2722
CLICKHOUSE_USER=default
2823
CLICKHOUSE_PASSWORD=
29-
30-
STRIPE_SECRET_KEY=
31-
STRIPE_WEBHOOK_SECRET=
32-
STRIPE_PRO_PLAN_PRICE_ID=
33-
STRIPE_PRO_PLAN_PRICE_ID_METERED=
34-
35-
SMTP_HOST=
36-
SMTP_PORT=
37-
SMTP_USER=
38-
SMTP_PASSWORD=
39-
SMTP_FROM=

packages/dashboard/app/components/AppBar.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
:to="`/organizations/${organization.id}`"
3232
variant="ghost"
3333
class="w-full"
34-
@click="selectOrganization(organization.id)"
3534
>
3635
<UAvatar :alt="organization.name" size="xs" />
3736
<span class="truncate">{{ organization.name }}</span>
@@ -113,7 +112,7 @@ const isDark = computed({
113112
},
114113
});
115114
116-
const { user, logout, selectOrganization } = await useAuth();
115+
const { user, logout } = await useAuth();
117116
118117
const { data: organizations } = await useFetch('/api/organizations');
119118

packages/dashboard/app/composables/auth.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export async function useAuth() {
33

44
const user = computed(() => data.value?.user ?? null);
55

6-
const isAuthenticated = computed(() => !!user.value?.id);
6+
const isAuthenticated = computed(() => !!user.value);
77

88
function login() {
99
window.location.href = '/api/auth/login';
@@ -13,21 +13,11 @@ export async function useAuth() {
1313
window.location.href = '/api/auth/logout';
1414
}
1515

16-
// TODO: select using link params and remove the currentOrganizationId property
17-
async function selectOrganization(organizationId: string) {
18-
await $fetch(`/api/user/`, {
19-
method: 'PATCH',
20-
body: JSON.stringify({ currentOrganizationId: organizationId }),
21-
});
22-
await updateAuthSession();
23-
}
24-
2516
return {
2617
isAuthenticated,
2718
user,
2819
login,
2920
logout,
30-
selectOrganization,
3121
updateAuthSession,
3222
};
3323
}

packages/dashboard/drizzle.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { defineConfig } from 'drizzle-kit';
44
export default defineConfig({
55
schema: './server/db/schema.ts',
66
out: './server/db/migrations',
7-
dialect: 'mysql',
7+
dialect: 'sqlite',
88
dbCredentials: {
9-
url: process.env.NUXT_DATABASE_URL || 'mysql://root:root@localhost:3306/drizzle',
9+
url: process.env.NUXT_DATABASE_URL || 'file:.data/lagoss.sqlite',
1010
},
1111
});

packages/dashboard/nuxt.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default defineNuxtConfig({
6969
forcePathStyle: true,
7070
},
7171
database: {
72-
url: 'mysql://root:lagoss@localhost:3306/lagoss',
72+
url: 'file:.data/lagoss.sqlite',
7373
},
7474
redis: {
7575
url: 'redis://localhost:6379',

packages/dashboard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@clickhouse/client": "^1.17.0",
2020
"@iconify-json/heroicons": "^1.2.3",
2121
"@iconify-json/ion": "^1.2.6",
22+
"@libsql/client": "^0.17.0",
2223
"@nuxt/ui": "^4.5.0",
2324
"@scaleway/use-random-name": "^1.0.10",
2425
"@types/nodemailer": "^7.0.11",
@@ -30,7 +31,6 @@
3031
"drizzle-orm": "^0.45.1",
3132
"is-in-subnet": "^4.0.1",
3233
"monaco-editor": "^0.55.1",
33-
"mysql2": "^3.18.0",
3434
"nodemailer": "^8.0.1",
3535
"nuxt": "^4.3.1",
3636
"nuxt-monaco-editor": "^1.3.2",

packages/dashboard/server/api/apps/[appId]/code.get.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ export default defineEventHandler(async event => {
3636
const db = await useDB();
3737
const app = await requireApp(event);
3838

39-
const deployment = await getFirst(
40-
db
41-
.select()
42-
.from(deploymentSchema)
43-
.where(and(eq(deploymentSchema.appId, app.id), eq(deploymentSchema.isProduction, 1)))
44-
.execute(),
45-
);
39+
const deployment = await db
40+
.select()
41+
.from(deploymentSchema)
42+
.where(and(eq(deploymentSchema.appId, app.id), eq(deploymentSchema.isProduction, true)))
43+
.get();
4644

4745
if (!deployment) {
4846
throw createError({

packages/dashboard/server/api/apps/[appId]/deployments/[deploymentId]/deploy.post.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ export default defineEventHandler(async event => {
1717
});
1818
}
1919

20-
const deployment = await getFirst(
21-
db
22-
.select()
23-
.from(deploymentSchema)
24-
.where(and(eq(deploymentSchema.id, deploymentId), eq(deploymentSchema.appId, app.id)))
25-
.execute(),
26-
);
20+
const deployment = await db
21+
.select()
22+
.from(deploymentSchema)
23+
.where(and(eq(deploymentSchema.id, deploymentId), eq(deploymentSchema.appId, app.id)))
24+
.get();
2725
if (!deployment) {
2826
throw createError({
2927
status: 404,
@@ -37,26 +35,24 @@ export default defineEventHandler(async event => {
3735
})
3836
.parseAsync(await readBody(event));
3937

40-
const hasProductionDeployment = await getFirst(
41-
db
42-
.select()
43-
.from(deploymentSchema)
44-
.where(and(eq(deploymentSchema.appId, app.id), eq(deploymentSchema.isProduction, 1)))
45-
.execute(),
46-
);
38+
const hasProductionDeployment = await db
39+
.select()
40+
.from(deploymentSchema)
41+
.where(and(eq(deploymentSchema.appId, app.id), eq(deploymentSchema.isProduction, true)))
42+
.get();
4743

4844
if (input.isProduction && hasProductionDeployment) {
4945
await db
5046
.update(deploymentSchema)
51-
.set({ isProduction: 0 })
47+
.set({ isProduction: false })
5248
.where(eq(deploymentSchema.appId, deployment.appId))
5349
.execute();
5450
}
5551

5652
await db
5753
.update(deploymentSchema)
5854
.set({
59-
isProduction: !hasProductionDeployment || input.isProduction ? 1 : 0,
55+
isProduction: !hasProductionDeployment || input.isProduction,
6056
})
6157
.where(eq(deploymentSchema.id, deploymentId))
6258
.execute();
@@ -75,7 +71,7 @@ export default defineEventHandler(async event => {
7571
cron: app.cron,
7672
cronRegion: app.cronRegion,
7773
env: envStringToObject(env),
78-
isProduction: deployment.isProduction === 1,
74+
isProduction: deployment.isProduction,
7975
assets: parseAssets(deployment.assets),
8076
});
8177

packages/dashboard/server/api/apps/[appId]/deployments/[deploymentId]/index.delete.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,19 @@ export default defineEventHandler(async event => {
1414
});
1515
}
1616

17-
const deployment = await getFirst(
18-
db
19-
.select()
20-
.from(deploymentSchema)
21-
.where(and(eq(deploymentSchema.id, deploymentId), eq(deploymentSchema.appId, app.id)))
22-
.execute(),
23-
);
17+
const deployment = await db
18+
.select()
19+
.from(deploymentSchema)
20+
.where(and(eq(deploymentSchema.id, deploymentId), eq(deploymentSchema.appId, app.id)))
21+
.get();
2422
if (!deployment) {
2523
throw createError({
2624
status: 404,
2725
message: 'Deployment not found',
2826
});
2927
}
3028

31-
if (deployment.isProduction === 1) {
29+
if (deployment.isProduction) {
3230
throw createError({
3331
status: 400,
3432
message: 'Cannot delete a production deployment, promote another deployment first.',

0 commit comments

Comments
 (0)