Skip to content

Commit b425e71

Browse files
authored
Beta fix m2m (#11)
1 parent 4e87c18 commit b425e71

18 files changed

Lines changed: 275 additions & 226 deletions

File tree

.github/workflows/code-quality.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
pull_request:
77
branches:
88
- main
9+
- drizzle-v1
910

1011
jobs:
1112
biome:

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
push:
1010
branches:
1111
- main
12+
- drizzle-v1
1213
paths-ignore:
1314
- 'docs/**'
1415
workflow_dispatch:

ARCHITECTURE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview
44

5-
**Bedstack (Stripped)** is a _distilled version_ of [the full Bedstack architecture](https://github.com/bedtime-coders/bedstack/blob/main/ARCHITECTURE.md). It keeps the _feature-sliced, modular structure_ but simplifies the layering for _rapid prototyping_.
5+
**Bedstack (Stripped)** is a _distilled version_ of [the full Bedstack architecture](https://github.com/bedtime-coders/bedstack/blob/drizzle-v1/ARCHITECTURE.md). It keeps the _feature-sliced, modular structure_ but simplifies the layering for _rapid prototyping_.
66

77
Each feature is self-contained and designed for clarity, fast development, and maintainability - without the overhead of full enterprise layering.
88

@@ -109,7 +109,7 @@ drizzle/ # Migrations, reset, seed
109109

110110
### See Also
111111

112-
- [Bedstack Full Architecture](https://github.com/bedtime-coders/bedstack/blob/main/ARCHITECTURE.md)
112+
- [Bedstack Full Architecture](https://github.com/bedtime-coders/bedstack/blob/drizzle-v1/ARCHITECTURE.md)
113113
- [ElysiaJS Docs](https://elysiajs.com/docs)
114114
- [Drizzle ORM Docs](https://orm.drizzle.team/docs)
115115
- [TypeBox Docs](https://typebox.io/docs)

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@
33
<img src="public/logo-mini.png" alt="Logo for Bedstack RealWorld example" width=200>
44
<h1>Bedstack (Stripped)</h1>
55

6-
[![Tests Status](https://github.com/bedtime-coders/bedstack-stripped/actions/workflows/tests.yml/badge.svg?event=push&branch=main&)](https://github.com/bedtime-coders/bedstac/actions/workflows/tests.yml?query=branch%3Amain+event%3Apush) [![Discord](https://img.shields.io/discord/1164270344115335320?label=Chat&color=5865f4&logo=discord&labelColor=121214)](https://discord.gg/8UcP9QB5AV) [![License](https://custom-icon-badges.demolab.com/github/license/bedtime-coders/bedstack-stripped?label=License&color=blue&logo=law&labelColor=0d1117)](https://github.com/bedtime-coders/bedstack-stripped/blob/main/LICENSE) [![Bun](https://img.shields.io/badge/Bun-14151a?logo=bun&logoColor=fbf0df)](https://bun.sh/) [![ElysiaJS](https://custom-icon-badges.demolab.com/badge/ElysiaJS-0f172b.svg?logo=elysia)](https://elysiajs.com/) [![Drizzle](https://img.shields.io/badge/Drizzle-C5F74F?logo=drizzle&logoColor=000)](https://drizzle.team/) [![Biome](https://img.shields.io/badge/Biome-24272f?logo=biome&logoColor=f6f6f9)](https://biomejs.dev/) [![Scalar](https://img.shields.io/badge/Scalar-080808?logo=scalar&logoColor=e7e7e7)](https://scalar.com/) [![Star](https://custom-icon-badges.demolab.com/github/stars/bedtime-coders/bedstack-stripped?logo=star&logoColor=373737&label=Star)](https://github.com/bedtime-coders/bedstack-stripped/stargazers/)
6+
[![Tests Status](https://github.com/bedtime-coders/bedstack-stripped/actions/workflows/tests.yml/badge.svg?event=push&branch=drizzle-v1&)](https://github.com/bedtime-coders/bedstac/actions/workflows/tests.yml?query=branch%drizzle-v1+event%3Apush) [![Discord](https://img.shields.io/discord/1164270344115335320?label=Chat&color=5865f4&logo=discord&labelColor=121214)](https://discord.gg/8UcP9QB5AV) [![License](https://custom-icon-badges.demolab.com/github/license/bedtime-coders/bedstack-stripped?label=License&color=blue&logo=law&labelColor=0d1117)](https://github.com/bedtime-coders/bedstack-stripped/blob/drizzle-v1/LICENSE) [![Bun](https://img.shields.io/badge/Bun-14151a?logo=bun&logoColor=fbf0df)](https://bun.sh/) [![ElysiaJS](https://custom-icon-badges.demolab.com/badge/ElysiaJS-0f172b.svg?logo=elysia)](https://elysiajs.com/) [![Drizzle](https://img.shields.io/badge/Drizzle-C5F74F?logo=drizzle&logoColor=000)](https://drizzle.team/) [![Biome](https://img.shields.io/badge/Biome-24272f?logo=biome&logoColor=f6f6f9)](https://biomejs.dev/) [![Scalar](https://img.shields.io/badge/Scalar-080808?logo=scalar&logoColor=e7e7e7)](https://scalar.com/) [![Star](https://custom-icon-badges.demolab.com/github/stars/bedtime-coders/bedstack-stripped?logo=star&logoColor=373737&label=Star)](https://github.com/bedtime-coders/bedstack-stripped/stargazers/)
77

88
⚡ Stripped version of [Bedstack](https://github.com/bedtime-coders/bedstack) for rapid prototyping
99

1010
</div>
1111

12+
> [!IMPORTANT]
13+
> You are viewing the **`drizzle-v1`** branch of _Bedstack (Stripped)_, where we use [Drizzle ORM v1, currently in beta](https://orm.drizzle.team/roadmap). Click [here](https://github.com/bedtime-coders/bedstack-stripped/tree/main) to view the main branch.
14+
15+
## Drizzle ORM v1 & Relational API v2
16+
17+
This branch uses [Drizzle ORM v1](https://orm.drizzle.team/roadmap), which is currently in beta. The main feature from Drizzle ORM v1 that we use here is Relational API v2 (often referred to as rqbv2).
18+
19+
- GitHub Discussion to learn more about Relational API v2: https://github.com/drizzle-team/drizzle-orm/discussions/2316.
20+
- Drizzle website page to track the release of Drizzle ORM v1: https://orm.drizzle.team/roadmap.
21+
1222
## Bedstack: Bun + ElysiaJS + Drizzle Stack
1323

1424
**Bedstack** is a collection of bleeding-edge technologies to build modern web applications.

scripts/db/reset.ts

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
1+
import { $ } from "bun";
12
import chalk from "chalk";
2-
import { drizzle } from "drizzle-orm/bun-sql";
3-
import { reset } from "drizzle-seed";
4-
import * as articlesSchema from "@/articles/articles.schema";
5-
import * as commentsSchema from "@/comments/comments.schema";
6-
import { env } from "@/core/env";
7-
import * as profilesSchema from "@/profiles/profiles.schema";
8-
import * as tagsSchema from "@/tags/tags.schema";
9-
import * as usersSchema from "@/users/users.schema";
10-
11-
const schema = {
12-
...usersSchema,
13-
...profilesSchema,
14-
...tagsSchema,
15-
...articlesSchema,
16-
...commentsSchema,
17-
};
3+
import { sql } from "drizzle-orm";
4+
import { db } from "@/core/database";
185

196
console.info(chalk.gray("Resetting database"));
20-
// See: https://github.com/drizzle-team/drizzle-orm/issues/3599
21-
await reset(drizzle(env.DATABASE_URL), schema);
7+
const query = sql`
8+
-- Delete all tables
9+
DO $$ DECLARE
10+
r RECORD;
11+
BEGIN
12+
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
13+
EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE';
14+
END LOOP;
15+
END $$;
16+
17+
-- Delete enums
18+
DO $$ DECLARE
19+
r RECORD;
20+
BEGIN
21+
FOR r IN (select t.typname as enum_name
22+
from pg_type t
23+
join pg_enum e on t.oid = e.enumtypid
24+
join pg_catalog.pg_namespace n ON n.oid = t.typnamespace
25+
where n.nspname = current_schema()) LOOP
26+
EXECUTE 'DROP TYPE IF EXISTS ' || quote_ident(r.enum_name);
27+
END LOOP;
28+
END $$;
29+
`;
30+
31+
await db.execute(query);
32+
33+
// Push the schema to the database
34+
await $`bun run db:push`.quiet();
2235
console.info(`[${chalk.green("✓")}] Database reset complete`);

0 commit comments

Comments
 (0)