RBAC, Permissions, and Export/Import
This commit is contained in:
71
deploy_rbac.sh
Executable file
71
deploy_rbac.sh
Executable file
@@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
# Quick deployment script for RBAC system
|
||||
# Run this on your dev server after pulling latest code
|
||||
|
||||
set -e # Exit on any error
|
||||
|
||||
echo "========================================"
|
||||
echo "RBAC System Deployment Script"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Check if .env exists
|
||||
if [ ! -f .env ]; then
|
||||
echo -e "${RED}Error: .env file not found${NC}"
|
||||
echo "Please create .env file with DATABASE_URL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Load environment variables
|
||||
source .env
|
||||
|
||||
# Function to check command success
|
||||
check_success() {
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${GREEN}✓ $1${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ $1 failed${NC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
echo -e "${YELLOW}Step 1: Running schema migration...${NC}"
|
||||
psql $DATABASE_URL -f migrations/006_add_dynamic_roles.sql
|
||||
check_success "Schema migration"
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}Step 2: Seeding system roles...${NC}"
|
||||
python3 roles_seed.py
|
||||
check_success "Roles seeding"
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}Step 3: Migrating users to dynamic roles...${NC}"
|
||||
python3 migrate_users_to_dynamic_roles.py
|
||||
check_success "User migration"
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}Step 4: Migrating role permissions...${NC}"
|
||||
python3 migrate_role_permissions_to_dynamic_roles.py
|
||||
check_success "Role permissions migration"
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}Step 5: Verifying admin account...${NC}"
|
||||
python3 verify_admin_account.py
|
||||
check_success "Admin account verification"
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo -e "${GREEN}✓ RBAC System Deployment Complete!${NC}"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "1. Restart your backend server"
|
||||
echo "2. Test the /api/admin/users/export endpoint"
|
||||
echo "3. Login as admin and check /admin/permissions page"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user