{"id":28496288,"url":"https://github.com/thechocomax/database","last_synced_at":"2025-07-02T15:30:37.777Z","repository":{"id":296787337,"uuid":"994362006","full_name":"TheChocoMax/Database","owner":"TheChocoMax","description":"PostgreSQL","archived":false,"fork":false,"pushed_at":"2025-06-17T02:44:41.000Z","size":61,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-17T03:31:18.104Z","etag":null,"topics":["database","postgresql"],"latest_commit_sha":null,"homepage":"","language":"SQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheChocoMax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-01T19:20:43.000Z","updated_at":"2025-06-08T16:38:40.000Z","dependencies_parsed_at":"2025-06-02T11:58:22.766Z","dependency_job_id":"a2b02eaa-753f-4a4a-a301-6703e6a28e5c","html_url":"https://github.com/TheChocoMax/Database","commit_stats":null,"previous_names":["thechocomax/database"],"tags_count":2,"template":false,"template_full_name":"Vianpyro/Template","purl":"pkg:github/TheChocoMax/Database","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheChocoMax%2FDatabase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheChocoMax%2FDatabase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheChocoMax%2FDatabase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheChocoMax%2FDatabase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheChocoMax","download_url":"https://codeload.github.com/TheChocoMax/Database/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheChocoMax%2FDatabase/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263165657,"owners_count":23423986,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","postgresql"],"created_at":"2025-06-08T12:07:08.785Z","updated_at":"2025-07-02T15:30:37.717Z","avatar_url":"https://github.com/TheChocoMax.png","language":"SQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PostgreSQL Database Generation\n\nThis repository contains SQL scripts to generate a database schema in Postgre.\nThe schema includes tables for managing users, articles, carts, orders, and more.\n\n## Getting Started\n\nTo set up the database locally, you'll need Docker installed. Follow the steps below to build and run the database in a container.\n\n### Setup Steps\n\n1. **Build the Docker Image**:\n\n   ```bash\n   docker build -t chocomax-database-image .\n   ```\n\n2. **Run the Docker Container**:\n\n   ```bash\n   docker run -d \\\n      -p 5432:5432 \\\n      --name chocomax-database-container \\\n      --env-file .env \\\n      --security-opt no-new-privileges:true \\\n      --cap-drop=ALL --cap-add=NET_BIND_SERVICE \\\n      chocomax-database-image\n   ```\n\n3. **Access the Database**:\n\n   ```bash\n   docker exec -it chocomax-database-container psql -h /run/postgresql -U postgres -d chocomax\n   ```\n\n## Database Schema Overview\n\nThe database schema consists of the following tables:\n\n1. **admin_accounts**: Stores admin-level user accounts with roles like superadmin, admin, or moderator.\n2. **admin_actions**: Logs actions taken by admin users for auditing purposes.\n3. **cart_items**: Represents the product variants added to a cart with their quantities.\n4. **carts**: Tracks user carts, including anonymous sessions.\n5. **category_translations**: Contains translated names and descriptions for product categories.\n6. **contact_messages**: Stores messages sent through the contact form by users or visitors.\n7. **discount_codes**: Defines promotional discount codes with rules and usage limits.\n8. **feedback**: Allows users to rate and comment on products they've purchased.\n9. **login_attempts**: Records login attempts with metadata like IP, user agent, and success flag.\n10. **loyalty_program**: Defines promotions such as \"buy X get Y\" for specific products.\n11. **metrics_events**: Stores anonymous event logs for analytics purposes.\n12. **moderation_actions**: Logs actions taken to moderate users, products, or comments.\n13. **order_delivery_info**: Stores delivery-related information such as address and delivery agent.\n14. **order_items**: Contains product variant items included in each order.\n15. **order_status_history**: Tracks the status changes of orders over time.\n16. **order_timestamps**: Keeps timestamps for different stages in the order lifecycle.\n17. **orders**: Main order records with price, status, and delivery type.\n18. **password_resets**: Stores reset tokens for users to change their passwords securely.\n19. **pending_users**: Manages email verification tokens and for new user.\n20. **product_categories**: Defines categories to group products (e.g., Chocolate, Gifts).\n21. **product_comments**: Stores user comments on products, optionally moderated.\n22. **product_images**: Manages images associated with products and their variants.\n23. **product_likes**: Tracks which users have liked which products.\n24. **product_translations**: Contains translated product names and descriptions.\n25. **product_variants**: Defines variations of a product (e.g., size or test versions).\n26. **products**: Stores product information like name, description, price, and status.\n27. **translations**: Generic key-value storage for UI translation strings across languages.\n28. **user_2fa**: Manages users' two-factor authentication settings and secrets.\n29. **user_discounts**: Tracks which discount codes a user has used.\n30. **user_loyalty_progress**: Tracks individual users’ progress in loyalty programs.\n31. **user_permissions**: Defines granular access permissions granted to users.\n32. **user_sessions**: Stores active session tokens and metadata for logged-in users.\n33. **users**: Main user table with account credentials and personal information.\n\nThe tables can be listed with the following command:\n\n```sql\nSELECT table_name FROM information_schema.tables WHERE table_schema = 'public';\n```\n\n## Usage\n\n1. **Clone the Repository**: Clone this repository to your local machine using `git clone`.\n\n2. **Execute SQL Scripts**: Run the provided SQL scripts in your Postgre environment to create the database schema.\n\n3. **Customization**: Modify the schema or add additional features as per your requirements.\n\n## Contributing\n\nContributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or create a pull request.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthechocomax%2Fdatabase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthechocomax%2Fdatabase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthechocomax%2Fdatabase/lists"}