Connect to Production Console
🚀 How to Connect to Mobayilo Production Console
Section titled “🚀 How to Connect to Mobayilo Production Console”Production is hosted on Dokploy. The database runs as a Docker service on the same VPS.
Option A: SSH + Docker (Recommended)
Section titled “Option A: SSH + Docker (Recommended)”Connect directly to the Postgres container running on the Dokploy server.
Step 1: SSH into the Server
Section titled “Step 1: SSH into the Server”ssh <user>@<your-dokploy-server-ip>Step 2: Find the Postgres Container
Section titled “Step 2: Find the Postgres Container”docker ps --filter "name=postgres" --format "table {{.Names}}\t{{.Status}}"Step 3: Access psql
Section titled “Step 3: Access psql”docker exec -it <postgres_container_name> psql -U <db_user> -d <db_name>Tip: If you don’t know the database name or user, check the environment variables in the Dokploy dashboard for the Mobayilo app service.
Step 4: Run Rails Console (Optional)
Section titled “Step 4: Run Rails Console (Optional)”If you need the Rails console instead of raw SQL, SSH into the server and run:
docker exec -it <mobayilo_app_container_name> bin/rails consoleOption B: Public Connection String
Section titled “Option B: Public Connection String”If you have exposed the Postgres port publicly (or are using an external managed database), connect directly from your local machine:
psql "postgresql://<USER>:<PASSWORD>@<HOST>:<PORT>/<DB_NAME>"Or run the Rails console locally with the production URL:
RAILS_ENV=production DATABASE_URL="postgresql://<USER>:<PASSWORD>@<HOST>:<PORT>/<DB_NAME>" bin/rails consoleThen force the connection:
ActiveRecord::Base.establish_connection("postgresql://<USER>:<PASSWORD>@<HOST>:<PORT>/<DB_NAME>")🛠️ Common Administrative Tasks
Section titled “🛠️ Common Administrative Tasks”Now that you are connected, here is how to handle your admin user:
Create or Update Admin
Section titled “Create or Update Admin”# This finds the user if they exist, or starts a new one if they don'tadmin = AdminUser.find_or_initialize_by(email: 'admin@example.com')
# Set/Reset the passwordadmin.password = '<SET_A_SECURE_PASSWORD>'admin.password_confirmation = '<SET_A_SECURE_PASSWORD>'
# Save to the live databaseadmin.save!Important: Never place real credentials in docs. Use placeholders like the above.
Verify Tables & Data
Section titled “Verify Tables & Data”# Count total adminsAdminUser.count
# List the last 5 users to joinUser.order(created_at: :desc).limit(5)
# Check a specific account balanceAccount.find_by(name: "Some Account").balance