jjn1056 / DBIx-Class-Migration

Use DBIC::DeploymentHandler and DBIC::Fixtures together for a sane database versioning workflow
33 stars 41 forks source link

Implement Upgrade/Downgrade scripts for first migration #95

Open KES777 opened 6 years ago

KES777 commented 6 years ago

When database is not versioned yet, but already exists it looks reasonable to generate upgrade/downgrade scripts which add/drop table for versioning:

MySQL/upgrade/0-1/001-auto.sql

CREATE TABLE `dbix_class_deploymenthandler_versions` (
  `id` integer NOT NULL auto_increment,
  `version` varchar(50) NOT NULL,
  `ddl` text NULL,
  `upgrade_sql` text NULL,
  PRIMARY KEY (`id`),
  UNIQUE `dbix_class_deploymenthandler_versions_version` (`version`)
);
SET foreign_key_checks=1;

MySQL/downgrade/1-0/001-auto.sql

DROP TABLE dbix_class_deploymenthandler_versions;

This will allow us to start versioning without deploying database from scratch

kivilahtio commented 6 years ago

It would be good to be able to deploy fixtures for the version1 as well.

mohawk2 commented 5 years ago

I would be open to a new Script command install_version_storage, which would leverage a provided (required) to_version argument by installing the version storage (not with a migration, unnecessary) with a call to DBICDH. Tests would be required, of course. I will not be implementing such myself at the present time.

Volunteers? :-)