ratemyclient/lib/my_first_elixir_vibe_code/release.ex
Kevin Sivic 9ece312442 Initial commit: RateMyClient™ Phoenix application
Features:
- User registration and authentication with email/password
- Admin login with username-based authentication (separate from regular users)
- Review system for contractors to rate clients
- Star rating system with review forms
- Client identification with private data protection
- Contractor registration with document verification
- Admin dashboard for review management
- Contact form (demo, non-functional)
- Responsive navigation with DaisyUI components
- Docker Compose setup for production deployment
- PostgreSQL database with Ecto migrations
- High Vis color scheme (dark background with safety orange/green)

Admin credentials: username: admin, password: admin123

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 21:30:50 -05:00

64 lines
1.7 KiB
Elixir

defmodule MyFirstElixirVibeCode.Release do
@moduledoc """
Used for executing DB release tasks when run in production without Mix
installed.
"""
@app :my_first_elixir_vibe_code
def create_db do
load_app()
for repo <- repos() do
case repo.__adapter__.storage_up(repo.config) do
:ok -> IO.puts("Database created for #{inspect(repo)}")
{:error, :already_up} -> IO.puts("Database already exists for #{inspect(repo)}")
{:error, term} -> IO.puts("Error creating database: #{inspect(term)}")
end
end
end
def migrate do
load_app()
for repo <- repos() do
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
end
end
def rollback(repo, version) do
load_app()
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
end
def seed_admin do
load_app()
for repo <- repos() do
{:ok, _, _} =
Ecto.Migrator.with_repo(repo, fn _repo ->
# Check if admin user already exists
case MyFirstElixirVibeCode.Repo.get_by(MyFirstElixirVibeCode.Accounts.User, username: "admin") do
nil ->
# Create admin user
MyFirstElixirVibeCode.Accounts.create_user(%{
username: "admin",
password: "admin123",
is_admin: true
})
IO.puts("Admin user created (username: admin, password: admin123)")
_user ->
IO.puts("Admin user already exists")
end
end)
end
end
defp repos do
Application.fetch_env!(@app, :ecto_repos)
end
defp load_app do
Application.load(@app)
end
end