Files
at-mintel/packages/cms-infra/scripts/bootstrap-schema.sh
Marc Mintel 9e4e296e3b
Some checks failed
Monorepo Pipeline / 🧪 Quality Assurance (push) Failing after 11s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Directus (Base) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
feat: adds aquisition extension to cms
2026-02-10 21:30:23 +01:00

76 lines
2.2 KiB
Bash

#!/bin/bash
# Configuration
API_URL="http://localhost:8059"
EMAIL="marc@mintel.me"
PASSWORD="Tim300493."
echo "Logging in to Directus..."
TOKEN=$(curl -s -X POST "${API_URL}/auth/login" \
-H "Content-Type: application/json" \
-d "{\"email\":\"${EMAIL}\", \"password\":\"${PASSWORD}\"}" | grep -o '"access_token":"[^"]*' | cut -d'"' -f4)
if [ -z "$TOKEN" ]; then
echo "Login failed!"
exit 1
fi
echo "Hiding 'leads' collection..."
curl -s -X PATCH "${API_URL}/collections/leads" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{"meta": {"hidden": true}}'
echo "Creating 'people' collection..."
curl -s -X POST "${API_URL}/collections" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"collection": "people",
"schema": {},
"meta": {
"icon": "person",
"display_template": "{{first_name}} {{last_name}}",
"show_status_indicator": true
}
}'
echo "Adding fields to 'people'..."
FIELDS='[
{"field": "first_name", "type": "string", "meta": {"interface": "input", "width": "half"}},
{"field": "last_name", "type": "string", "meta": {"interface": "input", "width": "half"}},
{"field": "email", "type": "string", "meta": {"interface": "input", "width": "half"}},
{"field": "phone", "type": "string", "meta": {"interface": "input", "width": "half"}},
{"field": "company", "type": "string", "meta": {"interface": "input", "width": "full"}}
]'
for field in $(echo "${FIELDS}" | jq -c '.[]'); do
curl -s -X POST "${API_URL}/fields/people" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d "${field}"
done
echo "Adding 'contact_person' to 'leads', 'client_users', and 'visual_feedback'..."
for collection in leads client_users visual_feedback; do
curl -s -X POST "${API_URL}/fields/${collection}" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"field": "contact_person",
"type": "uuid",
"meta": {
"interface": "select-dropdown-m2o",
"options": {
"template": "{{first_name}} {{last_name}}"
}
},
"schema": {
"foreign_key_column": "id",
"foreign_key_table": "people"
}
}'
done
echo "Done!"