{"id":18284493,"url":"https://github.com/pplu/dbix-dbflow","last_synced_at":"2025-04-09T05:46:50.116Z","repository":{"id":56834564,"uuid":"431930487","full_name":"pplu/dbix-dbflow","owner":"pplu","description":"A set of helper scripts to automate DBIx::DeploymentHandler","archived":false,"fork":false,"pushed_at":"2021-11-25T18:01:51.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T00:25:55.162Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","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/pplu.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":"2021-11-25T17:41:53.000Z","updated_at":"2021-11-25T18:01:31.000Z","dependencies_parsed_at":"2022-09-09T18:00:37.280Z","dependency_job_id":null,"html_url":"https://github.com/pplu/dbix-dbflow","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pplu%2Fdbix-dbflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pplu%2Fdbix-dbflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pplu%2Fdbix-dbflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pplu%2Fdbix-dbflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pplu","download_url":"https://codeload.github.com/pplu/dbix-dbflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987107,"owners_count":21028891,"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":[],"created_at":"2024-11-05T13:13:44.341Z","updated_at":"2025-04-09T05:46:50.087Z","avatar_url":"https://github.com/pplu.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nDBIx::DBFlow - Database development helpers\n\n# SYNOPSIS\n\nin your cpanfile add the following\n\n    requires 'DBIx::DBFlow::Runtime';\n\n    on develop =\u003e sub {\n      requires 'DBIx::DBFlow';\n    }\n\n# USAGE\n\n## Using the DBFlow on a new project:\n\nCreate the database in MySQL (tables, fks, etc)\n\n    dbflow_refresh_model --schema MySchema --dbh \"DBD:mysql...\"\n\nThis will create lib/MySchema.pm. Add this code to it:\n\n    our $VERSION = 1;\n    \n    sub admin_connection {\n      my $schema = __PACKAGE__-\u003econnect(\n        \"DBI:mysql:mysql_read_default_file=pathtoadmincreds.cnf;mysql_read_default_group=schema_group\",\n        undef,\n        undef,\n        {\n          AutoCommit =\u003e 1,\n          RaiseError =\u003e 1,\n          mysql_enable_utf8 =\u003e 1,\n          quote_char =\u003e '`',\n          name_sep   =\u003e '.',\n        },\n      );\n    }\n\nNow install the DBFlow with\n\n    dbflow_create --schema MySchema\n\nCreates a \"database\" directory with the deploy info for the database. Creates a handler table in your schema\n\n## Using the DBFlow\n\nBefore modifying the database, bump up it's version (you're about to produce what will be the next version \nof the database, so we have to signal that)\n\nModify the database with your favorite tool (HeidiSQL, mysql CLI, etc). Add columns, indexes, etc.\n\n    dbflow_refresh_model --schema MySchema\n\nThis will regenerate lib/MySchema\n\nYou can still tweak the database more times (add more columns, change types, etc). You have to execute \n`dbflow_refresh_model` each time, in order to refresh the DBIx::Class model\n\nWhen you're happy with your changes, and want to produce an upgrade:\n\n    dbflow_make_upgrade_scripts --schema MySchema\n\nThis creates a `database/MySQL/upgrade/X-Y/___.sql` file that contains the SQL instructions to migrate\nfrom version X to version Y.\n\nYou can create your own (new) SQL files in the same directory that will be executed on upgrade, for operations \nthat cannot be automatically derived (suppose you have to UPDATE some values on a table), although it's better\nto create Perl files that do the updating with the model (so you don't have to implement complex logic in SQL).\n\nCreate a `database/_common/upgrade/X-Y/01-upgrade_step.pl` file (where Y corresponds the version you are producing,\nand X to the previous one). Put this code in it:\n\n    sub {\n      my $model = shift;\n    \n      my $things = $model-\u003eresultset('Things')-\u003esearch({ ... });\n    }\n\nDo whatever perlish things you want in the update script, and please use the model to do it.\n\nyou can test the updating all the times you want with `make obliviatedb` and `dbflow_upgrade_schema --schema MySchema`\nuntil you are sure that the update will work in production.\n\n## Updating the production database\n\n    dbflow_upgrade_schema --schema MySchema\n\nIn production all you have to do is execute `dbflow_upgrade_schema`.\n\n# Interesting utilities\n\n## Visualizing your schema\n\nYou can visualize your schema with\n\n    dbflow_schema_diagram --schema MySchema\n\nIt will generate a PNG image called MySchema\\_schema.png\n\nYou can control the dimensions of the image with `--height` and `--width` parameters.\n\nYou can also specify the name of the file to write to with `--file`.\n\n# FAQ\n\n## MySchema.pm cannot be found\n\nThe 'lib' directory in the current directory is automatically included (your schema should be there).\nYou can use the `-I` option to specify an alternate, or try executing with a PERL5LIB that points to the \nappropiate directory with your schema.\n\n## I have more than one schema to manage in my project\n\nAll utils let you specify the schema name you're acting upon with `--schema` and the directory\nto create the upgrade/deploy scripts `--dir`\n\n# CONTRIBUTE\n\nThe source code and issues are on https://github.com/pplu/dbix-dbflow\n\n# AUTHOR\n    Jose Luis Martinez\n    CPAN ID: JLMARTIN\n    pplusdomain@gmail.com\n\n# COPYRIGHT and LICENSE\n\nCopyright (c) 2016 by Jose Luis Martinez Torres\n\nThis code is distributed under the Apache 2 License. The full text of the \nlicense can be found in the LICENSE file included with this module.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpplu%2Fdbix-dbflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpplu%2Fdbix-dbflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpplu%2Fdbix-dbflow/lists"}