Skip to content

Commit 94e756f

Browse files
committed
v0.2.1 rel
- manual_migration_timestamp: local tz -> utc - lazyprisma --version
1 parent 52e8cdc commit 94e756f

File tree

6 files changed

+87
-20
lines changed

6 files changed

+87
-20
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Binary name
22
BINARY_NAME=lazyprisma
3-
VERSION ?= 0.2.0
3+
VERSION ?= 0.2.1
44

55
# Directories
66
BUILD_DIR=build

README.md

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
# LazyPrisma
22

3-
Terminal UI tool for managing Prisma migrations and database.
3+
A Terminal UI tool for managing Prisma migrations and the database, designed for developers who prefer the command line.
44

55
<img width="1458" height="918" alt="image" src="https://github.com/user-attachments/assets/71c2db93-b784-4a0b-9740-7bb3710c4caf" />
66

7+
> **Note on Appearance**: The screenshot above features the **Dracula Dark** theme and **JetBrains Mono Nerd Font**. We highly recommend using a [Nerd Font](https://www.nerdfonts.com/) for the best visual experience, as future updates will introduce more icons and symbols.
8+
9+
## Features
10+
11+
- **Visualise Migrations**: View Local, Pending, and DB-Only migrations in a clean, organised TUI.
12+
- **Safe Workflow**: Built-in validations for checksum mismatches and empty migrations to prevent database inconsistencies.
13+
- **Prisma Studio Integration**: Toggle Prisma Studio directly from the app (`S` key) with automatic process management (no more zombie processes).
14+
- **Migration Management**: Create (`d`), Deploy (`D`), and Resolve (`s`) migrations effortlessly.
15+
- **Quick Actions**: Delete pending migrations (`Del`/`Backspace`) and copy migration details to the clipboard (`c`).
16+
717
## Installation
818

919
### Homebrew (macOS/Linux)
@@ -16,35 +26,68 @@ brew install lazyprisma
1626
Download the latest binary from [Releases](https://github.com/DokaDev/lazyprisma/releases).
1727

1828
## Prerequisites
19-
LazyPrisma requires Prisma CLI to be installed in your project:
29+
30+
LazyPrisma requires the Prisma CLI to be installed in your project:
31+
2032
```bash
2133
npm install -D prisma
2234
```
2335

24-
> **Note:** LazyPrisma uses `npx prisma` to execute commands. Global Prisma installation is not currently supported.
36+
> **Note:** LazyPrisma uses `npx prisma` to execute commands. Ensure `npx` is available in your shell path. It supports both the classic `schema.prisma` and the new Prisma v7+ `prisma.config.ts`.
2537
2638
## Usage
39+
40+
Navigate to your project directory and launch the application:
41+
2742
```bash
2843
cd your-prisma-project
2944
lazyprisma
3045
```
3146

47+
Check the version:
48+
```bash
49+
lazyprisma --version
50+
```
51+
3252
### Keyboard Shortcuts
33-
- `←/→` - Switch panels
34-
- `↑/↓` - Scroll/Select
35-
- `r` - Refresh migration status
36-
- `g` - Generate Prisma Client
37-
- `d` - Migrate Dev (create new migration)
38-
- `D` - Migrate Deploy
39-
- `f` - Format schema
40-
- `t` - Open Prisma Studio
41-
- `?` - Help
42-
- `q` - Quit
53+
54+
**Navigation**
55+
- `` / ``: Switch between panels (Workspace, Migrations, Details, Output).
56+
- `` / ``: Scroll list or text content.
57+
- `Tab` / `Shift+Tab`: Switch tabs within a panel (e.g., Local / Pending / DB-Only).
58+
59+
**Core Actions**
60+
- `r`: **Refresh** all panels and migration status.
61+
- `d`: **Migrate Dev** – Create a new migration (Schema diff-based or empty Manual migration).
62+
- `D`: **Migrate Deploy** – Apply pending migrations to the database.
63+
- `g`: **Generate** – Run `prisma generate` to update the client.
64+
- `s`: **Resolve** – Fix failed migrations (mark as applied or rolled back).
65+
- `S`: **Studio** – Toggle the Prisma Studio server (opens in your default browser).
66+
67+
**Utilities**
68+
- `c`: **Copy** – Copy the selected migration's name, path, or checksum to the clipboard.
69+
- `` / `Del`: **Delete** – Delete the selected pending local migration folder.
70+
- `q`: **Quit** – Exit the application (safely terminates any background Prisma Studio processes).
4371

4472
## Build from Source
45-
```bash
46-
brew install make
4773

74+
Ensure you have Go installed (1.21+ recommended).
75+
76+
```bash
77+
# Clean and build
4878
make clean
4979
make
80+
81+
# Build and run immediately
82+
83+
make run
84+
5085
```
86+
87+
88+
89+
## Roadmap
90+
91+
92+
93+
- **Automatic `down.sql` Generation**: Initially planned for v0.2.x, but postponed due to technical constraints. We aim to implement this feature in a future sprint, alongside establishing a robust `lazytui` framework and refactoring the codebase.

captures/v0.2.1/capture.jpg

423 KB
Loading

main.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@ import (
1111
_ "github.com/dokadev/lazyprisma/pkg/database/drivers"
1212
)
1313

14+
const (
15+
Version = "v0.2.1"
16+
Developer = "DokaLab"
17+
)
18+
1419
func main() {
20+
// Handle version flag
21+
if len(os.Args) > 1 {
22+
if os.Args[1] == "--version" || os.Args[1] == "-v" {
23+
fmt.Printf("LazyPrisma %s (%s)\n", Version, Developer)
24+
os.Exit(0)
25+
}
26+
}
27+
1528
// Check if current directory is a Prisma workspace
1629
cwd, err := os.Getwd()
1730
if err != nil {
@@ -31,8 +44,8 @@ func main() {
3144
tuiApp, err := app.NewApp(app.AppConfig{
3245
DebugMode: false,
3346
AppName: "LazyPrisma",
34-
Version: "v0.2.0",
35-
Developer: "DokaLab",
47+
Version: Version,
48+
Developer: Developer,
3649
})
3750
if err != nil {
3851
fmt.Fprintf(os.Stderr, "Failed to create app: %v\n", err)

pkg/app/app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,8 @@ func (a *App) createManualMigration(migrationName string) {
838838
return
839839
}
840840

841-
// Generate timestamp (YYYYMMDDHHmmss format)
842-
timestamp := time.Now().Format("20060102150405")
841+
// Generate timestamp (YYYYMMDDHHmmss format) in UTC to match Prisma CLI behavior
842+
timestamp := time.Now().UTC().Format("20060102150405")
843843
folderName := fmt.Sprintf("%s_%s", timestamp, migrationName)
844844

845845
// Migration folder path (prisma/migrations/{timestamp}_{name})

pkg/prisma/datasource.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ func extractURLFromConfig(projectDir, configPath string) (string, string, bool,
114114
defer file.Close()
115115

116116
scanner := bufio.NewScanner(file)
117+
// Match: url: env("DATABASE_URL")
117118
envRegex := regexp.MustCompile(`url:\s*env\(['"]([^'"]+)['"]\)`)
119+
// Match: url: process.env['DATABASE_URL']
120+
processEnvRegex := regexp.MustCompile(`url:\s*process\.env\[['"]([^'"]+)['"]\]`)
121+
// Match: url: "mysql://..."
118122
hardcodedRegex := regexp.MustCompile(`url:\s*['"]([^'"]+)['"]`)
119123

120124
for scanner.Scan() {
@@ -127,6 +131,13 @@ func extractURLFromConfig(projectDir, configPath string) (string, string, bool,
127131
return url, envVar, false, nil
128132
}
129133

134+
// Check for process.env usage
135+
if match := processEnvRegex.FindStringSubmatch(line); match != nil {
136+
envVar := match[1]
137+
url := resolveEnvVar(projectDir, envVar)
138+
return url, envVar, false, nil
139+
}
140+
130141
// Check for hardcoded URL
131142
if match := hardcodedRegex.FindStringSubmatch(line); match != nil {
132143
url := match[1]

0 commit comments

Comments
 (0)