Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
branches:
- main
- drizzle-v1

jobs:
biome:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
push:
branches:
- main
- drizzle-v1
paths-ignore:
- 'docs/**'
workflow_dispatch:
Expand Down
4 changes: 2 additions & 2 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

**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_.
**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_.

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

Expand Down Expand Up @@ -109,7 +109,7 @@ drizzle/ # Migrations, reset, seed

### See Also

- [Bedstack Full Architecture](https://github.com/bedtime-coders/bedstack/blob/main/ARCHITECTURE.md)
- [Bedstack Full Architecture](https://github.com/bedtime-coders/bedstack/blob/drizzle-v1/ARCHITECTURE.md)
- [ElysiaJS Docs](https://elysiajs.com/docs)
- [Drizzle ORM Docs](https://orm.drizzle.team/docs)
- [TypeBox Docs](https://typebox.io/docs)
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@
<img src="public/logo-mini.png" alt="Logo for Bedstack RealWorld example" width=200>
<h1>Bedstack (Stripped)</h1>

[![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/)
[![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/)

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

</div>

> [!IMPORTANT]
> 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.

## Drizzle ORM v1 & Relational API v2

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).

- GitHub Discussion to learn more about Relational API v2: https://github.com/drizzle-team/drizzle-orm/discussions/2316.
- Drizzle website page to track the release of Drizzle ORM v1: https://orm.drizzle.team/roadmap.

## Bedstack: Bun + ElysiaJS + Drizzle Stack

**Bedstack** is a collection of bleeding-edge technologies to build modern web applications.
Expand Down
49 changes: 31 additions & 18 deletions scripts/db/reset.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
import { $ } from "bun";
import chalk from "chalk";
import { drizzle } from "drizzle-orm/bun-sql";
import { reset } from "drizzle-seed";
import * as articlesSchema from "@/articles/articles.schema";
import * as commentsSchema from "@/comments/comments.schema";
import { env } from "@/core/env";
import * as profilesSchema from "@/profiles/profiles.schema";
import * as tagsSchema from "@/tags/tags.schema";
import * as usersSchema from "@/users/users.schema";

const schema = {
...usersSchema,
...profilesSchema,
...tagsSchema,
...articlesSchema,
...commentsSchema,
};
import { sql } from "drizzle-orm";
import { db } from "@/core/database";

console.info(chalk.gray("Resetting database"));
// See: https://github.com/drizzle-team/drizzle-orm/issues/3599
await reset(drizzle(env.DATABASE_URL), schema);
const query = sql`
-- Delete all tables
DO $$ DECLARE
r RECORD;
BEGIN
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE';
END LOOP;
END $$;

-- Delete enums
DO $$ DECLARE
r RECORD;
BEGIN
FOR r IN (select t.typname as enum_name
from pg_type t
join pg_enum e on t.oid = e.enumtypid
join pg_catalog.pg_namespace n ON n.oid = t.typnamespace
where n.nspname = current_schema()) LOOP
EXECUTE 'DROP TYPE IF EXISTS ' || quote_ident(r.enum_name);
END LOOP;
END $$;
`;

await db.execute(query);

// Push the schema to the database
await $`bun run db:push`.quiet();
console.info(`[${chalk.green("✓")}] Database reset complete`);
Loading