Repository navigation
feat: implement unified role naming system #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| -- Migration: Update user role default from 'user' to 'member' | ||
| -- Aligns schema with unified role naming system | ||
|
|
||
| -- Step 1: Backfill existing rows (update any 'user' roles to 'member') | ||
| UPDATE "user" SET "role" = 'member' WHERE "role" = 'user'; | ||
|
|
||
| -- Step 2: Set new default for future inserts | ||
| ALTER TABLE "user" ALTER COLUMN "role" SET DEFAULT 'member'; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ export const user = pgTable("user", { | |
| image: text("image"), | ||
| createdAt: timestamp("createdAt").notNull(), | ||
| updatedAt: timestamp("updatedAt").notNull(), | ||
| role: text("role").default("user"), | ||
| role: text("role").default("member"), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Search for migration files in common locations
echo "=== Looking for migration files ==="
find . -type f \( -name "*migration*" -o -name "*migrate*" \) | head -30
echo ""
echo "=== Looking for SQL files in drizzle or migrations directories ==="
find . -type d \( -name "*migration*" -o -name "*migrate*" -o -name "*drizzle*" \) 2>/dev/null
echo ""
echo "=== Searching for SQL files ==="
fd --type f '\.sql$' | head -30
echo ""
echo "=== Searching for files referencing role default or member ==="
rg "role.*member|member.*role" --type sql 2>/dev/null | head -20Repository: pramodnarayana/nexiom Length of output: 914 🏁 Script executed: #!/bin/bash
# Check the migration files in packages/identity/drizzle
echo "=== Migration files in packages/identity/drizzle/ ==="
ls -la packages/identity/drizzle/
echo ""
echo "=== Content of 0000_sudden_silver_surfer.sql ==="
cat packages/identity/drizzle/0000_sudden_silver_surfer.sql
echo ""
echo "=== Content of 0001_workable_santa_claus.sql ==="
cat packages/identity/drizzle/0001_workable_santa_claus.sqlRepository: pramodnarayana/nexiom Length of output: 2345 🏁 Script executed: #!/bin/bash
# Read the schema.ts file around line 23
echo "=== Content of packages/identity/src/schema.ts around line 23 ==="
cat -n packages/identity/src/schema.ts | sed -n '1,50p'Repository: pramodnarayana/nexiom Length of output: 2060 🏁 Script executed: #!/bin/bash
# Check the drizzle meta directory for metadata about schema changes
echo "=== Content of packages/identity/drizzle/meta ==="
ls -la packages/identity/drizzle/meta/
echo ""
echo "=== Check git status for schema changes ==="
cd packages/identity && git diff src/schema.ts 2>/dev/null || echo "Git diff not available"
echo ""
echo "=== Check if schema file was recently modified ==="
cd packages/identity && git log --oneline -5 -- src/schema.ts 2>/dev/null || echo "Git log not available"
echo ""
echo "=== Check migration meta files ==="
cat packages/identity/drizzle/meta/_journal.json 2>/dev/null || echo "Journal file not found"Repository: pramodnarayana/nexiom Length of output: 694 🏁 Script executed: #!/bin/bash
# Read the journal file directly
echo "=== Content of packages/identity/drizzle/meta/_journal.json ==="
cat packages/identity/drizzle/meta/_journal.json
echo ""
echo "=== Check if latest snapshot (0001) contains role default ==="
grep -A 2 -B 2 '"role"' packages/identity/drizzle/meta/0001_snapshot.json | head -20Repository: pramodnarayana/nexiom Length of output: 1000 🏁 Script executed: #!/bin/bash
# Extract and format the user table definition from the latest snapshot
echo "=== User table definition from 0001_snapshot.json ==="
python3 << 'PYTHON_EOF'
import json
with open('packages/identity/drizzle/meta/0001_snapshot.json', 'r') as f:
snapshot = json.load(f)
# Find the user table
if 'public.user' in snapshot['schema']['tables']:
user_table = snapshot['schema']['tables']['public.user']
print(json.dumps(user_table, indent=2))
else:
print("User table not found in snapshot")
PYTHON_EOFRepository: pramodnarayana/nexiom Length of output: 227 🏁 Script executed: #!/bin/bash
# First, let's see the actual structure of the snapshot
echo "=== Structure of 0001_snapshot.json ==="
python3 << 'PYTHON_EOF'
import json
with open('packages/identity/drizzle/meta/0001_snapshot.json', 'r') as f:
snapshot = json.load(f)
# Print top-level keys
print("Top-level keys:", list(snapshot.keys()))
print()
# Look for user table
for key in snapshot.keys():
if 'user' in str(snapshot[key]).lower() and isinstance(snapshot[key], dict):
print(f"Found 'user' in key: {key}")
# Try to find the user table definition
tables = snapshot.get('tables', {})
if not tables:
# Try other possible keys
for key in snapshot:
if isinstance(snapshot[key], dict) and any('user' in str(k).lower() for k in snapshot[key].keys()):
tables = snapshot[key]
print(f"Found tables under key: {key}")
break
# Search for user table
for table_name, table_def in tables.items():
if 'user' in table_name.lower():
print(f"\nUser table: {table_name}")
if 'columns' in table_def:
for col_name, col_def in table_def['columns'].items():
if col_name == 'role':
print(f" {col_name}: {col_def}")
PYTHON_EOFRepository: pramodnarayana/nexiom Length of output: 396 A database migration is required for the role default change. The schema.ts file has been updated to set the user role default to Generate a new Drizzle migration to alter the user table and update the role column default value from 🤖 Prompt for AI Agents |
||
| banned: boolean("banned"), | ||
| banReason: text("banReason"), | ||
| banExpires: timestamp("banExpires"), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.