only update selected recording entries, set timestamp on creating and modifying

This commit is contained in:
Milan
2018-01-18 16:28:34 +01:00
parent cec1a0fdcc
commit 459d36b7c7
4 changed files with 73 additions and 17 deletions

View File

@@ -234,5 +234,7 @@ cat calcmsOld.sql | mysql -u root calcmsOld
cat calcmsNew.sql | mysql -u root calcmsNew cat calcmsNew.sql | mysql -u root calcmsNew
mysqldiff --force --changes-for=server2 --difftype=sql calcmsOld:calcmsNew > migrate.sql mysqldiff --force --changes-for=server2 --difftype=sql calcmsOld:calcmsNew > migrate.sql
# make sure lines with "modified_at" contain "ON UPDATE CURRENT_TIMESTAMP"
# for example: `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
cat migrate | mysql -u root calcms cat migrate | mysql -u root calcms

View File

@@ -37,7 +37,7 @@ CREATE TABLE `calcms_audio_recordings` (
`rmsRight` float DEFAULT NULL, `rmsRight` float DEFAULT NULL,
`mastered` tinyint(1) DEFAULT '0', `mastered` tinyint(1) DEFAULT '0',
`processed` tinyint(1) DEFAULT '0', `processed` tinyint(1) DEFAULT '0',
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `project_index` (`project_id`), KEY `project_index` (`project_id`),
KEY `studio_index` (`studio_id`), KEY `studio_index` (`studio_id`),
@@ -142,7 +142,7 @@ CREATE TABLE `calcms_event_history` (
`excerpt` longtext, `excerpt` longtext,
`content` longtext, `content` longtext,
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`rating` int(11) DEFAULT NULL, `rating` int(11) DEFAULT NULL,
`status` varchar(40) DEFAULT NULL, `status` varchar(40) DEFAULT NULL,
`visibility` varchar(40) DEFAULT NULL, `visibility` varchar(40) DEFAULT NULL,
@@ -227,7 +227,7 @@ CREATE TABLE `calcms_events` (
`excerpt` longtext, `excerpt` longtext,
`content` longtext, `content` longtext,
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`rating` int(11) DEFAULT NULL, `rating` int(11) DEFAULT NULL,
`status` varchar(40) DEFAULT NULL, `status` varchar(40) DEFAULT NULL,
`visibility` varchar(40) DEFAULT NULL, `visibility` varchar(40) DEFAULT NULL,
@@ -303,14 +303,14 @@ DROP TABLE IF EXISTS `calcms_images`;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `calcms_images` ( CREATE TABLE `calcms_images` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime DEFAULT NULL, `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
`description` text, `description` text,
`name` varchar(300) DEFAULT NULL, `name` varchar(300) DEFAULT NULL,
`filename` varchar(64) NOT NULL, `filename` varchar(64) NOT NULL,
`created_by` varchar(64) DEFAULT NULL, `created_by` varchar(64) DEFAULT NULL,
`studio_id` int(10) unsigned DEFAULT NULL, `studio_id` int(10) unsigned DEFAULT NULL,
`modified_by` varchar(64) DEFAULT NULL, `modified_by` varchar(64) DEFAULT NULL,
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`project_id` int(10) unsigned NOT NULL, `project_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `created_at` (`created_at`), KEY `created_at` (`created_at`),
@@ -525,8 +525,8 @@ CREATE TABLE `calcms_roles` (
`read_role` tinyint(1) unsigned DEFAULT NULL, `read_role` tinyint(1) unsigned DEFAULT NULL,
`update_role` tinyint(1) unsigned DEFAULT NULL, `update_role` tinyint(1) unsigned DEFAULT NULL,
`delete_user` tinyint(1) unsigned DEFAULT NULL, `delete_user` tinyint(1) unsigned DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL, `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`update_event_of_series` tinyint(1) unsigned DEFAULT NULL, `update_event_of_series` tinyint(1) unsigned DEFAULT NULL,
`update_event_of_others` tinyint(1) unsigned DEFAULT NULL, `update_event_of_others` tinyint(1) unsigned DEFAULT NULL,
`studio_id` int(10) unsigned NOT NULL, `studio_id` int(10) unsigned NOT NULL,
@@ -622,10 +622,10 @@ CREATE TABLE `calcms_series` (
`image` varchar(200) DEFAULT NULL, `image` varchar(200) DEFAULT NULL,
`project` varchar(64) DEFAULT NULL, `project` varchar(64) DEFAULT NULL,
`location` varchar(100) DEFAULT NULL, `location` varchar(100) DEFAULT NULL,
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`modified_by` varchar(100) NOT NULL, `modified_by` varchar(100) NOT NULL,
`category` varchar(60) DEFAULT NULL, `category` varchar(60) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL, `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`assign_event_series_name` varchar(100) DEFAULT NULL, `assign_event_series_name` varchar(100) DEFAULT NULL,
`assign_event_title` varchar(100) DEFAULT NULL, `assign_event_title` varchar(100) DEFAULT NULL,
`default_duration` int(10) unsigned DEFAULT NULL, `default_duration` int(10) unsigned DEFAULT NULL,
@@ -843,8 +843,8 @@ CREATE TABLE `calcms_studios` (
`location` varchar(100) NOT NULL, `location` varchar(100) NOT NULL,
`stream` varchar(100) NOT NULL, `stream` varchar(100) NOT NULL,
`google_calendar` varchar(100) NOT NULL, `google_calendar` varchar(100) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL, `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`image` varchar(200) NOT NULL, `image` varchar(200) NOT NULL,
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `name_2` (`name`), UNIQUE KEY `name_2` (`name`),
@@ -902,7 +902,7 @@ CREATE TABLE `calcms_user_events` (
`title` varchar(200) DEFAULT NULL, `title` varchar(200) DEFAULT NULL,
`excerpt` longtext, `excerpt` longtext,
`content` longtext, `content` longtext,
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`modified_by` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `modified_by` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`status` varchar(40) DEFAULT NULL, `status` varchar(40) DEFAULT NULL,
`program` varchar(40) DEFAULT NULL, `program` varchar(40) DEFAULT NULL,
@@ -938,8 +938,8 @@ CREATE TABLE `calcms_user_roles` (
`user_id` int(10) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL,
`role_id` int(10) unsigned NOT NULL, `role_id` int(10) unsigned NOT NULL,
`studio_id` int(10) unsigned NOT NULL DEFAULT '0', `studio_id` int(10) unsigned NOT NULL DEFAULT '0',
`created_at` timestamp NULL DEFAULT NULL, `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`project_id` int(10) unsigned NOT NULL, `project_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
KEY `user_id` (`user_id`), KEY `user_id` (`user_id`),
@@ -972,7 +972,7 @@ CREATE TABLE `calcms_user_series` (
`series_id` int(10) unsigned NOT NULL, `series_id` int(10) unsigned NOT NULL,
`active` char(1) NOT NULL, `active` char(1) NOT NULL,
`modified_by` varchar(100) DEFAULT NULL, `modified_by` varchar(100) DEFAULT NULL,
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`studio_id` int(10) unsigned NOT NULL, `studio_id` int(10) unsigned NOT NULL,
`project_id` int(10) unsigned NOT NULL, `project_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
@@ -1069,8 +1069,8 @@ CREATE TABLE `calcms_users` (
`salt` varchar(32) NOT NULL, `salt` varchar(32) NOT NULL,
`pass` varchar(100) NOT NULL, `pass` varchar(100) NOT NULL,
`email` varchar(300) DEFAULT NULL, `email` varchar(300) DEFAULT NULL,
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created_at` timestamp NULL DEFAULT NULL, `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`disabled` int(10) unsigned DEFAULT '0', `disabled` int(10) unsigned DEFAULT '0',
`session_timeout` int(10) unsigned NOT NULL DEFAULT '120', `session_timeout` int(10) unsigned NOT NULL DEFAULT '120',
`created_by` varchar(30) DEFAULT NULL, `created_by` varchar(30) DEFAULT NULL,

View File

@@ -31,3 +31,53 @@ ALTER TABLE `calcms_series_schedule`
CHANGE COLUMN start_offset start_offset int(11) NULL DEFAULT '0', CHANGE COLUMN start_offset start_offset int(11) NULL DEFAULT '0',
CHANGE COLUMN nextDay nextDay int(11) NULL DEFAULT '0'; CHANGE COLUMN nextDay nextDay int(11) NULL DEFAULT '0';
ALTER TABLE `calcms_audio_recordings`
CHANGE COLUMN modified_at modified_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
ALTER TABLE `calcms_event_history`
CHANGE COLUMN created_at created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE `calcms_events`
CHANGE COLUMN created_at created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE `calcms_images`
CHANGE COLUMN created_at created_at datetime NULL DEFAULT CURRENT_TIMESTAMP,
CHANGE COLUMN modified_at modified_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
ALTER TABLE `calcms_roles`
CHANGE COLUMN modified_at modified_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
CHANGE COLUMN created_at created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE `calcms_series`
CHANGE COLUMN created_at created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP,
CHANGE COLUMN modified_at modified_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
ALTER TABLE `calcms_studios`
CHANGE COLUMN created_at created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP,
CHANGE COLUMN modified_at modified_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
ALTER TABLE `calcms_user_events`
CHANGE COLUMN modified_at modified_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
ALTER TABLE `calcms_user_roles`
CHANGE COLUMN created_at created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP,
CHANGE COLUMN modified_at modified_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
ALTER TABLE `calcms_user_series`
CHANGE COLUMN modified_at modified_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
ALTER TABLE `calcms_users`
CHANGE COLUMN created_at created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP,
CHANGE COLUMN modified_at modified_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;

View File

@@ -140,6 +140,10 @@ sub update{
rmsLeft=?, rmsRight=? rmsLeft=?, rmsRight=?
where project_id=? and studio_id=? and event_id=? where project_id=? and studio_id=? and event_id=?
}; };
if (defined $entry->{id}){
$query.=' and id=?';
push @$bind_values, $entry->{id};
}
#print STDERR Dumper($query).Dumper($bind_values); #print STDERR Dumper($query).Dumper($bind_values);
return db::put($dbh, $query, $bind_values); return db::put($dbh, $query, $bind_values);
} }