{"id":19500234,"url":"https://github.com/joelniemela/maggy","last_synced_at":"2025-04-25T23:30:23.248Z","repository":{"id":50699133,"uuid":"519857663","full_name":"JoelNiemela/Maggy","owner":"JoelNiemela","description":"SQL Migration Tool","archived":false,"fork":false,"pushed_at":"2022-11-06T20:16:06.000Z","size":2563,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T04:51:08.694Z","etag":null,"topics":["cli","macros","migration-tool","sql"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/JoelNiemela.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}},"created_at":"2022-07-31T18:34:17.000Z","updated_at":"2022-12-14T18:35:00.000Z","dependencies_parsed_at":"2023-01-22T09:45:20.993Z","dependency_job_id":null,"html_url":"https://github.com/JoelNiemela/Maggy","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoelNiemela%2FMaggy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoelNiemela%2FMaggy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoelNiemela%2FMaggy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoelNiemela%2FMaggy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoelNiemela","download_url":"https://codeload.github.com/JoelNiemela/Maggy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250912660,"owners_count":21506865,"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":["cli","macros","migration-tool","sql"],"created_at":"2024-11-10T22:07:57.709Z","updated_at":"2025-04-25T23:30:22.981Z","avatar_url":"https://github.com/JoelNiemela.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Maggy — An SQL Migration Tool ##\r\n\r\nMaggy is a tool written in PHP to facilitate the making and applying of migrations for SQL databases.\r\n\r\n## Installation ##\r\n\r\nIn order to install Maggy:\r\n- Clone this repository `git clone https://github.com/JoelNiemela/Maggy.git`\r\n- Download an SQL server, such as `mariadb`\r\n- Configure `config.ini` to connect to your database\r\n\r\n## Maggy files ##\r\n\r\nIn Maggy, each migration is described by a Maggy file. Maggy files consist of vanilla SQL with Maggy macros that enable `maggy migrate` and `maggy rollback`.\r\n\r\nMaggy files end with the `.sql.maggy` file extension;\r\n\r\nAn example Maggy file:\r\n```sql\r\n--@Version 42 \"Add user table\"\r\n\r\n--@Up\r\nCREATE TABLE IF NOT EXISTS user (\r\n  user_id INT AUTO_INCREMENT PRIMARY KEY,\r\n  name VARCHAR(255) NOT NULL,\r\n  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\r\n);\r\n\r\n--@Down\r\nDROP TABLE user;\r\n```\r\n\r\n## Maggy Syntax ##\r\n\r\nThere are three types of Macros in Maggy:\r\n- Segment macros (`--@Segment`):\r\n  - Introduce new segments, such as `--@Up` and `--@Down`.\r\n  - Declare the context of a file with the `--@Version` macro.\r\n- Attribute macros (`--#Attribute`):\r\n  - Modify the behavior of SQL queries or other macros.\r\n- Command macros (`--!Command`):\r\n  - Enable Maggy for a database with the `--!Maggy` macro.\r\n  - Shorthand for SQL queries.\r\n\r\nEvery Maggy file must start with the `--@Version` macro.\r\n\r\n\r\n### Full list of macros ###\r\n- `--@Version [version] [description]`\r\n  - Declare migration version of a file, along with a short description describing the migration.\r\n- `--@Up`\r\n  - Initiates the `Up` segment; all subsequent lines (until the next segment macro) belong to the `Up` segment.\r\n- `--@Down`\r\n  - Initiates the `Down` segment; all subsequent lines (until the next segment macro) belong to the `Down` segment.\r\n- `--!Maggy`\r\n  - Enables Maggy support for the database. The first migration for a database with Maggy should use this command.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelniemela%2Fmaggy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoelniemela%2Fmaggy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelniemela%2Fmaggy/lists"}