Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fcdfdb4588 | |||
| 6bbaa8d105 | |||
| eccc084441 |
@@ -13,8 +13,8 @@
|
|||||||
"cms:push:infra": "./scripts/sync-directus.sh push infra",
|
"cms:push:infra": "./scripts/sync-directus.sh push infra",
|
||||||
"cms:pull:infra": "./scripts/sync-directus.sh pull infra",
|
"cms:pull:infra": "./scripts/sync-directus.sh pull infra",
|
||||||
"cms:schema:snapshot": "./scripts/cms-snapshot.sh",
|
"cms:schema:snapshot": "./scripts/cms-snapshot.sh",
|
||||||
"cms:schema:snapshot:infra": "./scripts/cms-snapshot.sh infra",
|
"cms:schema:apply": "./scripts/cms-apply.sh local",
|
||||||
"cms:schema:apply": "./scripts/cms-apply.sh",
|
"cms:schema:apply:infra": "./scripts/cms-apply.sh infra",
|
||||||
"dev:infra": "docker-compose up -d directus directus-db",
|
"dev:infra": "docker-compose up -d directus directus-db",
|
||||||
"release": "pnpm build && changeset publish",
|
"release": "pnpm build && changeset publish",
|
||||||
"release:tag": "pnpm build && pnpm -r publish --no-git-checks --access public",
|
"release:tag": "pnpm build && pnpm -r publish --no-git-checks --access public",
|
||||||
|
|||||||
Binary file not shown.
@@ -126,9 +126,9 @@ fields:
|
|||||||
schema:
|
schema:
|
||||||
name: id
|
name: id
|
||||||
table: client_users
|
table: client_users
|
||||||
data_type: char
|
data_type: uuid
|
||||||
default_value: null
|
default_value: null
|
||||||
max_length: 36
|
max_length: null
|
||||||
numeric_precision: null
|
numeric_precision: null
|
||||||
numeric_scale: null
|
numeric_scale: null
|
||||||
is_nullable: false
|
is_nullable: false
|
||||||
@@ -304,7 +304,7 @@ fields:
|
|||||||
foreign_key_column: null
|
foreign_key_column: null
|
||||||
- collection: client_users
|
- collection: client_users
|
||||||
field: company
|
field: company
|
||||||
type: string
|
type: uuid
|
||||||
meta:
|
meta:
|
||||||
collection: client_users
|
collection: client_users
|
||||||
conditions: null
|
conditions: null
|
||||||
@@ -328,9 +328,9 @@ fields:
|
|||||||
schema:
|
schema:
|
||||||
name: company
|
name: company
|
||||||
table: client_users
|
table: client_users
|
||||||
data_type: char
|
data_type: uuid
|
||||||
default_value: null
|
default_value: null
|
||||||
max_length: 36
|
max_length: null
|
||||||
numeric_precision: null
|
numeric_precision: null
|
||||||
numeric_scale: null
|
numeric_scale: null
|
||||||
is_nullable: true
|
is_nullable: true
|
||||||
@@ -450,9 +450,9 @@ fields:
|
|||||||
schema:
|
schema:
|
||||||
name: id
|
name: id
|
||||||
table: companies
|
table: companies
|
||||||
data_type: char
|
data_type: uuid
|
||||||
default_value: null
|
default_value: null
|
||||||
max_length: 36
|
max_length: null
|
||||||
numeric_precision: null
|
numeric_precision: null
|
||||||
numeric_scale: null
|
numeric_scale: null
|
||||||
is_nullable: false
|
is_nullable: false
|
||||||
@@ -617,7 +617,7 @@ fields:
|
|||||||
width: full
|
width: full
|
||||||
- collection: directus_users
|
- collection: directus_users
|
||||||
field: company
|
field: company
|
||||||
type: string
|
type: uuid
|
||||||
meta:
|
meta:
|
||||||
collection: directus_users
|
collection: directus_users
|
||||||
conditions: null
|
conditions: null
|
||||||
@@ -641,9 +641,9 @@ fields:
|
|||||||
schema:
|
schema:
|
||||||
name: company
|
name: company
|
||||||
table: directus_users
|
table: directus_users
|
||||||
data_type: char
|
data_type: uuid
|
||||||
default_value: null
|
default_value: null
|
||||||
max_length: 36
|
max_length: null
|
||||||
numeric_precision: null
|
numeric_precision: null
|
||||||
numeric_scale: null
|
numeric_scale: null
|
||||||
is_nullable: true
|
is_nullable: true
|
||||||
@@ -869,7 +869,7 @@ fields:
|
|||||||
foreign_key_column: null
|
foreign_key_column: null
|
||||||
- collection: visual_feedback
|
- collection: visual_feedback
|
||||||
field: user_created
|
field: user_created
|
||||||
type: string
|
type: uuid
|
||||||
meta:
|
meta:
|
||||||
collection: visual_feedback
|
collection: visual_feedback
|
||||||
conditions: null
|
conditions: null
|
||||||
@@ -894,9 +894,9 @@ fields:
|
|||||||
schema:
|
schema:
|
||||||
name: user_created
|
name: user_created
|
||||||
table: visual_feedback
|
table: visual_feedback
|
||||||
data_type: char
|
data_type: uuid
|
||||||
default_value: null
|
default_value: null
|
||||||
max_length: 36
|
max_length: null
|
||||||
numeric_precision: null
|
numeric_precision: null
|
||||||
numeric_scale: null
|
numeric_scale: null
|
||||||
is_nullable: true
|
is_nullable: true
|
||||||
@@ -934,9 +934,9 @@ fields:
|
|||||||
schema:
|
schema:
|
||||||
name: screenshot
|
name: screenshot
|
||||||
table: visual_feedback
|
table: visual_feedback
|
||||||
data_type: char
|
data_type: uuid
|
||||||
default_value: null
|
default_value: null
|
||||||
max_length: 36
|
max_length: null
|
||||||
numeric_precision: null
|
numeric_precision: null
|
||||||
numeric_scale: null
|
numeric_scale: null
|
||||||
is_nullable: true
|
is_nullable: true
|
||||||
@@ -950,7 +950,7 @@ fields:
|
|||||||
foreign_key_column: null
|
foreign_key_column: null
|
||||||
- collection: visual_feedback
|
- collection: visual_feedback
|
||||||
field: company
|
field: company
|
||||||
type: string
|
type: uuid
|
||||||
meta:
|
meta:
|
||||||
collection: visual_feedback
|
collection: visual_feedback
|
||||||
conditions: null
|
conditions: null
|
||||||
@@ -974,9 +974,9 @@ fields:
|
|||||||
schema:
|
schema:
|
||||||
name: company
|
name: company
|
||||||
table: visual_feedback
|
table: visual_feedback
|
||||||
data_type: char
|
data_type: uuid
|
||||||
default_value: null
|
default_value: null
|
||||||
max_length: 36
|
max_length: null
|
||||||
numeric_precision: null
|
numeric_precision: null
|
||||||
numeric_scale: null
|
numeric_scale: null
|
||||||
is_nullable: true
|
is_nullable: true
|
||||||
@@ -1072,7 +1072,7 @@ fields:
|
|||||||
foreign_key_column: null
|
foreign_key_column: null
|
||||||
- collection: visual_feedback_comments
|
- collection: visual_feedback_comments
|
||||||
field: user_created
|
field: user_created
|
||||||
type: string
|
type: uuid
|
||||||
meta:
|
meta:
|
||||||
collection: visual_feedback_comments
|
collection: visual_feedback_comments
|
||||||
conditions: null
|
conditions: null
|
||||||
@@ -1097,9 +1097,9 @@ fields:
|
|||||||
schema:
|
schema:
|
||||||
name: user_created
|
name: user_created
|
||||||
table: visual_feedback_comments
|
table: visual_feedback_comments
|
||||||
data_type: char
|
data_type: uuid
|
||||||
default_value: null
|
default_value: null
|
||||||
max_length: 36
|
max_length: null
|
||||||
numeric_precision: null
|
numeric_precision: null
|
||||||
numeric_scale: null
|
numeric_scale: null
|
||||||
is_nullable: true
|
is_nullable: true
|
||||||
|
|||||||
@@ -6,6 +6,12 @@
|
|||||||
|
|
||||||
- Add `turbopack: {}` to support Next.js 16 default Turbopack behavior when a webpack config is present.
|
- Add `turbopack: {}` to support Next.js 16 default Turbopack behavior when a webpack config is present.
|
||||||
|
|
||||||
|
## 1.6.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Add `turbopack: {}` to support Next.js 16 default Turbopack behavior when a webpack config is present.
|
||||||
|
|
||||||
## 1.0.1
|
## 1.0.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mintel/next-config",
|
"name": "@mintel/next-config",
|
||||||
"version": "1.6.0",
|
"version": "1.6.1",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public",
|
"access": "public",
|
||||||
"registry": "https://npm.infra.mintel.me"
|
"registry": "https://npm.infra.mintel.me"
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ENV=$1
|
# Configuration
|
||||||
|
PROJECT="infra-cms"
|
||||||
|
LOCAL_SCHEMA_PATH="./packages/cms-infra/schema/snapshot.yaml"
|
||||||
REMOTE_HOST="root@infra.mintel.me"
|
REMOTE_HOST="root@infra.mintel.me"
|
||||||
REMOTE_DIR="/opt/infra/directus"
|
REMOTE_DIR="/opt/infra/directus"
|
||||||
|
|
||||||
|
ENV=$1
|
||||||
|
|
||||||
if [ -z "$ENV" ]; then
|
if [ -z "$ENV" ]; then
|
||||||
echo "Usage: ./scripts/cms-apply.sh [local|infra]"
|
echo "Usage: ./scripts/cms-apply.sh [local|infra]"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -11,38 +15,55 @@ fi
|
|||||||
|
|
||||||
case $ENV in
|
case $ENV in
|
||||||
local)
|
local)
|
||||||
CONTAINER=$(docker compose ps -q directus)
|
PROJECT="infra-cms"
|
||||||
if [ -z "$CONTAINER" ]; then
|
CMD_PREFIX="docker-compose -f packages/cms-infra/docker-compose.yml"
|
||||||
echo "❌ Local directus container not found."
|
|
||||||
|
LOCAL_CONTAINER=$($CMD_PREFIX ps -q $PROJECT)
|
||||||
|
if [ -z "$LOCAL_CONTAINER" ]; then
|
||||||
|
echo "❌ Local $PROJECT container not found. Is it running?"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "🚀 Applying schema locally..."
|
|
||||||
docker exec "$CONTAINER" npx directus schema apply /directus/schema/snapshot.yaml --yes
|
echo "🚀 Applying schema to LOCAL $PROJECT..."
|
||||||
|
docker exec "$LOCAL_CONTAINER" npx directus schema apply -y /directus/schema/snapshot.yaml
|
||||||
;;
|
;;
|
||||||
infra)
|
infra)
|
||||||
PROJECT_NAME="directus"
|
# 'infra' is the remote production server for at-mintel
|
||||||
|
PROJECT="directus" # Remote project name
|
||||||
echo "📤 Uploading snapshot to $ENV..."
|
|
||||||
# Ensure remote directory exists
|
|
||||||
ssh "$REMOTE_HOST" "mkdir -p $REMOTE_DIR/directus/schema"
|
|
||||||
scp ./directus/schema/snapshot.yaml "$REMOTE_HOST:$REMOTE_DIR/directus/schema/snapshot.yaml"
|
|
||||||
|
|
||||||
echo "🔍 Detecting remote container..."
|
echo "🔍 Detecting remote container..."
|
||||||
REMOTE_CONTAINER=$(ssh "$REMOTE_HOST" "cd $REMOTE_DIR && docker compose -p $PROJECT_NAME ps -q directus")
|
REMOTE_CONTAINER=$(ssh "$REMOTE_HOST" "docker ps --filter label=com.docker.compose.project=$PROJECT --filter label=com.docker.compose.service=directus -q")
|
||||||
|
|
||||||
|
if [ -z "$REMOTE_CONTAINER" ]; then
|
||||||
|
# Fallback to older name if labels fail
|
||||||
|
REMOTE_CONTAINER=$(ssh "$REMOTE_HOST" "docker ps -f name=directus-directus-1 -q")
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$REMOTE_CONTAINER" ]; then
|
if [ -z "$REMOTE_CONTAINER" ]; then
|
||||||
echo "❌ Remote container for $ENV not found."
|
echo "❌ Remote container for $ENV not found."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "📦 Syncing extensions to REMOTE $ENV..."
|
||||||
|
# Ensure remote directory exists
|
||||||
|
ssh "$REMOTE_HOST" "mkdir -p $REMOTE_DIR/extensions"
|
||||||
|
rsync -avz --delete ./packages/cms-infra/extensions/ "$REMOTE_HOST:$REMOTE_DIR/extensions/"
|
||||||
|
|
||||||
echo "🚀 Applying schema to $ENV..."
|
echo "📤 Injecting snapshot directly into container $REMOTE_CONTAINER..."
|
||||||
ssh "$REMOTE_HOST" "docker exec $REMOTE_CONTAINER npx directus schema apply /directus/schema/snapshot.yaml --yes"
|
# Inject file via stdin to avoid needing a host-side mount or scp path matching
|
||||||
|
ssh "$REMOTE_HOST" "docker exec -i $REMOTE_CONTAINER sh -c 'cat > /tmp/snapshot.yaml'" < "$LOCAL_SCHEMA_PATH"
|
||||||
|
|
||||||
echo "🔄 Restarting Directus to clear cache..."
|
echo "🚀 Applying schema to REMOTE $ENV..."
|
||||||
ssh "$REMOTE_HOST" "cd $REMOTE_DIR && docker compose -p $PROJECT_NAME restart directus"
|
ssh "$REMOTE_HOST" "docker exec $REMOTE_CONTAINER npx directus schema apply -y /tmp/snapshot.yaml"
|
||||||
|
|
||||||
|
echo "🔄 Restarting remote Directus to clear cache..."
|
||||||
|
ssh "$REMOTE_HOST" "cd $REMOTE_DIR && docker compose restart directus"
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
ssh "$REMOTE_HOST" "docker exec $REMOTE_CONTAINER rm /tmp/snapshot.yaml"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "❌ Invalid environment: $ENV. Only 'local' and 'infra' are supported."
|
echo "❌ Invalid environment: $ENV. Supported: local, infra."
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -1,17 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
PROJECT="directus"
|
PROJECT="infra-cms"
|
||||||
SCHEMA_PATH="./directus/schema/snapshot.yaml"
|
SCHEMA_PATH="./packages/cms-infra/schema/snapshot.yaml"
|
||||||
CMD_PREFIX=""
|
CMD_PREFIX="docker-compose -f packages/cms-infra/docker-compose.yml"
|
||||||
|
|
||||||
if [ "$1" == "infra" ]; then
|
|
||||||
PROJECT="infra-cms"
|
|
||||||
SCHEMA_PATH="./packages/cms-infra/schema/snapshot.yaml"
|
|
||||||
CMD_PREFIX="docker-compose -f packages/cms-infra/docker-compose.yml"
|
|
||||||
else
|
|
||||||
CMD_PREFIX="docker compose"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Detect local container
|
# Detect local container
|
||||||
LOCAL_CONTAINER=$($CMD_PREFIX ps -q $PROJECT)
|
LOCAL_CONTAINER=$($CMD_PREFIX ps -q $PROJECT)
|
||||||
@@ -21,8 +13,11 @@ if [ -z "$LOCAL_CONTAINER" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "📸 Creating schema snapshot for $PROJECT..."
|
echo "📸 Creating schema snapshot for local $PROJECT..."
|
||||||
# Note: we save it to the mounted volume path inside the container
|
# Note: we save it to the mounted volume path inside the container
|
||||||
docker exec "$LOCAL_CONTAINER" npx directus schema snapshot -y /directus/schema/snapshot.yaml
|
docker exec "$LOCAL_CONTAINER" npx directus schema snapshot -y /directus/schema/snapshot.yaml
|
||||||
|
|
||||||
echo "✅ Snapshot saved to $SCHEMA_PATH"
|
echo "🛠️ Repairing snapshot for Postgres compatibility..."
|
||||||
|
python3 ./scripts/fix_snapshot_v3.py
|
||||||
|
|
||||||
|
echo "✅ Snapshot saved and repaired at $SCHEMA_PATH"
|
||||||
|
|||||||
96
scripts/fix_snapshot_v3.py
Normal file
96
scripts/fix_snapshot_v3.py
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
path = '/Users/marcmintel/Projects/at-mintel/packages/cms-infra/schema/snapshot.yaml'
|
||||||
|
if not os.path.exists(path):
|
||||||
|
print(f"File not found: {path}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
with open(path, 'r') as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
|
||||||
|
new_lines = []
|
||||||
|
current_collection = None
|
||||||
|
current_field = None
|
||||||
|
in_schema = False
|
||||||
|
|
||||||
|
fix_fields = {'id', 'company', 'user_created', 'user_updated', 'screenshot', 'logo', 'feedback_id'}
|
||||||
|
uuid_fields = {'id', 'company', 'user_created', 'user_updated'}
|
||||||
|
|
||||||
|
# For multi-pass logic
|
||||||
|
snapshot_has_feedback_id = False
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
stripped = line.strip()
|
||||||
|
|
||||||
|
if stripped.startswith('- collection:'):
|
||||||
|
current_collection = stripped.split(':')[-1].strip()
|
||||||
|
in_schema = False
|
||||||
|
elif stripped.startswith('field:'):
|
||||||
|
current_field = stripped.split(':')[-1].strip()
|
||||||
|
if current_collection == 'visual_feedback_comments' and current_field == 'feedback_id':
|
||||||
|
snapshot_has_feedback_id = True
|
||||||
|
elif stripped == 'schema:':
|
||||||
|
in_schema = True
|
||||||
|
elif stripped == 'meta:' or stripped.startswith('- collection:') or (not line.startswith(' ') and line.strip() and not line.startswith('-')):
|
||||||
|
in_schema = False
|
||||||
|
|
||||||
|
# Top-level field type
|
||||||
|
if not in_schema and stripped.startswith('type:') and current_field in uuid_fields:
|
||||||
|
line = line.replace('type: string', 'type: uuid')
|
||||||
|
|
||||||
|
# Schema data type
|
||||||
|
if in_schema and current_field in fix_fields:
|
||||||
|
if 'data_type: char' in line or 'data_type: varchar' in line:
|
||||||
|
line = line.replace('data_type: char', 'data_type: uuid').replace('data_type: varchar', 'data_type: uuid')
|
||||||
|
if 'max_length:' in line:
|
||||||
|
line = ' max_length: null\n'
|
||||||
|
|
||||||
|
new_lines.append(line)
|
||||||
|
|
||||||
|
# Handle Missing feedback_id Injection
|
||||||
|
if not snapshot_has_feedback_id:
|
||||||
|
# We find systemFields and inject before it
|
||||||
|
injected = False
|
||||||
|
final_lines = []
|
||||||
|
feedback_id_block = """ - collection: visual_feedback_comments
|
||||||
|
field: feedback_id
|
||||||
|
type: integer
|
||||||
|
meta:
|
||||||
|
collection: visual_feedback_comments
|
||||||
|
field: feedback_id
|
||||||
|
interface: select-dropdown-m2o
|
||||||
|
required: true
|
||||||
|
sort: 4
|
||||||
|
width: full
|
||||||
|
schema:
|
||||||
|
name: feedback_id
|
||||||
|
table: visual_feedback_comments
|
||||||
|
data_type: integer
|
||||||
|
is_nullable: false
|
||||||
|
is_indexed: true
|
||||||
|
foreign_key_table: visual_feedback
|
||||||
|
foreign_key_column: id
|
||||||
|
"""
|
||||||
|
for line in new_lines:
|
||||||
|
if 'systemFields:' in line and not injected:
|
||||||
|
final_lines.append(feedback_id_block)
|
||||||
|
injected = True
|
||||||
|
final_lines.append(line)
|
||||||
|
new_lines = final_lines
|
||||||
|
|
||||||
|
# Second pass for primary key nullability
|
||||||
|
final_lines = []
|
||||||
|
for i in range(len(new_lines)):
|
||||||
|
line = new_lines[i]
|
||||||
|
if 'is_primary_key: true' in line:
|
||||||
|
# Search backwards and forwards
|
||||||
|
for j in range(max(0, i-10), min(len(new_lines), i+10)):
|
||||||
|
if 'is_nullable: true' in new_lines[j]:
|
||||||
|
new_lines[j] = new_lines[j].replace('is_nullable: true', 'is_nullable: false')
|
||||||
|
final_lines.append(line)
|
||||||
|
|
||||||
|
with open(path, 'w') as f:
|
||||||
|
f.writelines(new_lines)
|
||||||
|
|
||||||
|
print("SUCCESS: Full normalization and field injection complete.")
|
||||||
Reference in New Issue
Block a user