Skip to content

Commit

Permalink
[api] Change Project & Package name type to String
Browse files Browse the repository at this point in the history
There is a validation for both Package and Project that limit their
names to 200 characters, so we should use string of 200 characters
instead of text in the database. There is also a validation to avoid
that the name is nil, so the field should be not nullable in the
database.
  • Loading branch information
Ana06 committed Jan 4, 2017
1 parent a7d6fd3 commit 6dbc195
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class ChangeProjectPackageNameToString < ActiveRecord::Migration[5.0]
def change
execute 'UPDATE projects SET name = SUBSTR(name, 1, 200)'
execute 'UPDATE projects SET name = "" WHERE name is null'
execute 'UPDATE packages SET name = SUBSTR(name, 1, 200)'
execute 'UPDATE packages SET name = "" WHERE name is null'
change_column :projects, :name, :string, limit: 200, null: false
change_column :packages, :name, :string, limit: 200, null: false
end
end
10 changes: 5 additions & 5 deletions src/api/db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ CREATE TABLE `package_kinds` (
CREATE TABLE `packages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`project_id` int(11) NOT NULL,
`name` text COLLATE utf8_bin,
`name` varchar(200) COLLATE utf8_bin NOT NULL,
`title` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`description` text CHARACTER SET utf8,
`created_at` datetime DEFAULT NULL,
Expand All @@ -717,7 +717,7 @@ CREATE TABLE `packages` (
`delta` tinyint(1) NOT NULL DEFAULT '1',
`releasename` varchar(255) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `packages_all_index` (`project_id`,`name`(255)),
UNIQUE KEY `packages_all_index` (`project_id`,`name`),
KEY `devel_package_id_index` (`develpackage_id`),
KEY `updated_at_index` (`updated_at`),
KEY `index_packages_on_project_id` (`project_id`),
Expand Down Expand Up @@ -816,7 +816,7 @@ CREATE TABLE `project_log_entries` (

CREATE TABLE `projects` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text COLLATE utf8_bin,
`name` varchar(200) COLLATE utf8_bin NOT NULL,
`title` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`description` text CHARACTER SET utf8,
`url` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
Expand All @@ -828,7 +828,7 @@ CREATE TABLE `projects` (
`delta` tinyint(1) NOT NULL DEFAULT '1',
`kind` enum('standard','maintenance','maintenance_incident','maintenance_release') COLLATE utf8_bin DEFAULT 'standard',
PRIMARY KEY (`id`),
UNIQUE KEY `projects_name_index` (`name`(255)),
UNIQUE KEY `projects_name_index` (`name`),
KEY `updated_at_index` (`updated_at`),
KEY `devel_project_id_index` (`develproject_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Expand Down Expand Up @@ -1100,6 +1100,6 @@ CREATE TABLE `watched_projects` (
CONSTRAINT `watched_projects_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

INSERT INTO schema_migrations (version) VALUES ('1'), ('10'), ('11'), ('12'), ('13'), ('14'), ('15'), ('16'), ('17'), ('18'), ('19'), ('2'), ('20'), ('20090701125033'), ('20090703100900'), ('20090716174522'), ('20090717114240'), ('20091017210000'), ('20091022210000'), ('20091022310000'), ('20091029100000'), ('20091030060000'), ('20091102060000'), ('20091111191005'), ('20091115101346'), ('20091117144409'), ('20091117152223'), ('20091118000000'), ('20091119000000'), ('20091119090108'), ('20091119090620'), ('20091124194151'), ('20091206194902'), ('20091209193452'), ('20091209211754'), ('20091226112028'), ('20091229115736'), ('20100102150000'), ('20100104170000'), ('20100109145739'), ('20100125100000'), ('20100202132416'), ('20100302100000'), ('20100304100000'), ('20100315100000'), ('20100316100000'), ('20100316100001'), ('20100327100000'), ('20100329191407'), ('20100423144748'), ('20100426144748'), ('20100428144748'), ('20100429144748'), ('20100506115929'), ('20100507115929'), ('20100530180617'), ('20100609100000'), ('20100609200000'), ('20100614121047'), ('20100629095208'), ('20100702082339'), ('20100705124948'), ('20100705133839'), ('20100705141045'), ('20100707061034'), ('20100805100000'), ('20100812100000'), ('20100827100000'), ('20100903100000'), ('20100927110821'), ('20100927132716'), ('20100927133955'), ('20100928081344'), ('20101110100000'), ('20110117000000'), ('20110131100000'), ('20110202100000'), ('20110202110000'), ('20110302100000'), ('20110303100000'), ('20110309100000'), ('20110318112742'), ('20110321000000'), ('20110322000000'), ('20110323000000'), ('2011033000000'), ('20110331001200'), ('20110404085232'), ('20110404085325'), ('20110404090700'), ('20110405151201'), ('20110502100000'), ('20110519000000'), ('20110527000000'), ('20110615083665'), ('20110615083666'), ('20110627001200'), ('20110703001200'), ('20110711001200'), ('20110719142500'), ('20110725105426'), ('20110728072502'), ('20111005000000'), ('20111116100002'), ('20111117162400'), ('20111122000000'), ('20111123000000'), ('20111206000000'), ('20111206151500'), ('20111207000000'), ('20111213000000'), ('20111215094300'), ('20111303000000'), ('20120110094300'), ('20120110104300'), ('20120111094300'), ('20120112094300'), ('20120112194300'), ('20120119194300'), ('20120119204300'), ('20120119204301'), ('20120120104301'), ('20120120114301'), ('20120124114301'), ('20120124114302'), ('20120124114303'), ('20120216114303'), ('20120217114303'), ('20120217114304'), ('20120220114304'), ('20120222105426'), ('20120223105426'), ('20120304205014'), ('20120312204300'), ('20120313113554'), ('20120313131909'), ('20120319104301'), ('20120319133739'), ('20120320134850'), ('20120407173644'), ('20120411112931'), ('20120411121152'), ('20120417115800'), ('20120418121859'), ('20120529150500'), ('20120903122955'), ('20120904122955'), ('20120907114304'), ('20121014124846'), ('20121015121807'), ('20121112104534'), ('20121112110642'), ('20121114093616'), ('20121120110642'), ('20121120124300'), ('20121121142111'), ('20121124032111'), ('20121130103300'), ('20121130143300'), ('20121213140751'), ('20121213144129'), ('20121216151549'), ('20121220151549'), ('20130111085930'), ('20130220160000'), ('20130301100000'), ('20130409123324'), ('20130410124738'), ('20130414061002'), ('20130603100244'), ('20130610100244'), ('20130612151549'), ('20130618083665'), ('20130621083665'), ('20130626160000'), ('20130627193722'), ('20130702083665'), ('20130702203665'), ('20130723055536'), ('20130725123636'), ('20130726144516'), ('20130802183104'), ('20130802183717'), ('20130802190951'), ('20130805073101'), ('20130807071147'), ('20130814071147'), ('20130816183104'), ('20130817082602'), ('20130819114303'), ('20130820151442'), ('20130830043205'), ('20130903114302'), ('20130904071147'), ('20130910162318'), ('20130917124132'), ('20130920090004'), ('20130930130128'), ('20131005225515'), ('20131006000000'), ('20131006162847'), ('20131020151037'), ('20131020165316'), ('20131021063641'), ('20131022114302'), ('20131023063641'), ('20131027122410'), ('20131028085325'), ('20131029112259'), ('20131105112259'), ('20131106112233'), ('20131111090310'), ('20131111193512'), ('20131111194720'), ('20131112140033'), ('20131120193512'), ('20131123113417'), ('20131124071042'), ('20131125071042'), ('20131125101042'), ('20131126074753'), ('20131126205430'), ('20131127091624'), ('20131209095749'), ('20131209103450'), ('20131210182719'), ('20131218071042'), ('20140113110551'), ('20140123063641'), ('20140123071042'), ('20140124071042'), ('20140210114542'), ('20140213101042'), ('20140218174400'), ('20140219185200'), ('20140516182719'), ('20140624101042'), ('20140627071042'), ('20140704101043'), ('20140709071042'), ('20140714112346'), ('20140717101042'), ('20140718112346'), ('20140721112346'), ('20140729101042'), ('20140801071042'), ('20140819071042'), ('20140821105426'), ('20140827105426'), ('20140903105426'), ('20140903125426'), ('20140908125426'), ('20140908135426'), ('20140916135426'), ('20140930135426'), ('20141001135426'), ('20141002130128'), ('20141002130129'), ('20141002231042'), ('20141022105426'), ('20141022205426'), ('20141107135426'), ('20141110105426'), ('20141125105426'), ('20141201135426'), ('20141202135426'), ('20141208135426'), ('20150112135426'), ('20150127135426'), ('20150129135426'), ('20150129135427'), ('20150227063641'), ('20150623063641'), ('20150625105426'), ('20150630135426'), ('20150715112346'), ('20150716112346'), ('20150716124906'), ('20150807105426'), ('20150902130939'), ('20150903084813'), ('20150916084813'), ('20151030130011'), ('20160321085300'), ('20160321104000'), ('20160321105300'), ('20160518105300'), ('20160610105300'), ('20160808135426'), ('20160819105300'), ('20160824132643'), ('20161019231042'), ('20161025231042'), ('20161115094035'), ('20161117135426'), ('20161121162349'), ('20161122121211'), ('20161122123708'), ('20161123124803'), ('20161124133941'), ('20161128115942'), ('21'), ('22'), ('23'), ('24'), ('25'), ('26'), ('27'), ('28'), ('29'), ('3'), ('30'), ('31'), ('32'), ('33'), ('34'), ('35'), ('36'), ('37'), ('38'), ('39'), ('4'), ('40'), ('41'), ('42'), ('43'), ('44'), ('45'), ('46'), ('47'), ('48'), ('5'), ('6'), ('7'), ('8'), ('9'), ('20161124135426');
INSERT INTO schema_migrations (version) VALUES ('1'), ('10'), ('11'), ('12'), ('13'), ('14'), ('15'), ('16'), ('17'), ('18'), ('19'), ('2'), ('20'), ('20090701125033'), ('20090703100900'), ('20090716174522'), ('20090717114240'), ('20091017210000'), ('20091022210000'), ('20091022310000'), ('20091029100000'), ('20091030060000'), ('20091102060000'), ('20091111191005'), ('20091115101346'), ('20091117144409'), ('20091117152223'), ('20091118000000'), ('20091119000000'), ('20091119090108'), ('20091119090620'), ('20091124194151'), ('20091206194902'), ('20091209193452'), ('20091209211754'), ('20091226112028'), ('20091229115736'), ('20100102150000'), ('20100104170000'), ('20100109145739'), ('20100125100000'), ('20100202132416'), ('20100302100000'), ('20100304100000'), ('20100315100000'), ('20100316100000'), ('20100316100001'), ('20100327100000'), ('20100329191407'), ('20100423144748'), ('20100426144748'), ('20100428144748'), ('20100429144748'), ('20100506115929'), ('20100507115929'), ('20100530180617'), ('20100609100000'), ('20100609200000'), ('20100614121047'), ('20100629095208'), ('20100702082339'), ('20100705124948'), ('20100705133839'), ('20100705141045'), ('20100707061034'), ('20100805100000'), ('20100812100000'), ('20100827100000'), ('20100903100000'), ('20100927110821'), ('20100927132716'), ('20100927133955'), ('20100928081344'), ('20101110100000'), ('20110117000000'), ('20110131100000'), ('20110202100000'), ('20110202110000'), ('20110302100000'), ('20110303100000'), ('20110309100000'), ('20110318112742'), ('20110321000000'), ('20110322000000'), ('20110323000000'), ('2011033000000'), ('20110331001200'), ('20110404085232'), ('20110404085325'), ('20110404090700'), ('20110405151201'), ('20110502100000'), ('20110519000000'), ('20110527000000'), ('20110615083665'), ('20110615083666'), ('20110627001200'), ('20110703001200'), ('20110711001200'), ('20110719142500'), ('20110725105426'), ('20110728072502'), ('20111005000000'), ('20111116100002'), ('20111117162400'), ('20111122000000'), ('20111123000000'), ('20111206000000'), ('20111206151500'), ('20111207000000'), ('20111213000000'), ('20111215094300'), ('20111303000000'), ('20120110094300'), ('20120110104300'), ('20120111094300'), ('20120112094300'), ('20120112194300'), ('20120119194300'), ('20120119204300'), ('20120119204301'), ('20120120104301'), ('20120120114301'), ('20120124114301'), ('20120124114302'), ('20120124114303'), ('20120216114303'), ('20120217114303'), ('20120217114304'), ('20120220114304'), ('20120222105426'), ('20120223105426'), ('20120304205014'), ('20120312204300'), ('20120313113554'), ('20120313131909'), ('20120319104301'), ('20120319133739'), ('20120320134850'), ('20120407173644'), ('20120411112931'), ('20120411121152'), ('20120417115800'), ('20120418121859'), ('20120529150500'), ('20120903122955'), ('20120904122955'), ('20120907114304'), ('20121014124846'), ('20121015121807'), ('20121112104534'), ('20121112110642'), ('20121114093616'), ('20121120110642'), ('20121120124300'), ('20121121142111'), ('20121124032111'), ('20121130103300'), ('20121130143300'), ('20121213140751'), ('20121213144129'), ('20121216151549'), ('20121220151549'), ('20130111085930'), ('20130220160000'), ('20130301100000'), ('20130409123324'), ('20130410124738'), ('20130414061002'), ('20130603100244'), ('20130610100244'), ('20130612151549'), ('20130618083665'), ('20130621083665'), ('20130626160000'), ('20130627193722'), ('20130702083665'), ('20130702203665'), ('20130723055536'), ('20130725123636'), ('20130726144516'), ('20130802183104'), ('20130802183717'), ('20130802190951'), ('20130805073101'), ('20130807071147'), ('20130814071147'), ('20130816183104'), ('20130817082602'), ('20130819114303'), ('20130820151442'), ('20130830043205'), ('20130903114302'), ('20130904071147'), ('20130910162318'), ('20130917124132'), ('20130920090004'), ('20130930130128'), ('20131005225515'), ('20131006000000'), ('20131006162847'), ('20131020151037'), ('20131020165316'), ('20131021063641'), ('20131022114302'), ('20131023063641'), ('20131027122410'), ('20131028085325'), ('20131029112259'), ('20131105112259'), ('20131106112233'), ('20131111090310'), ('20131111193512'), ('20131111194720'), ('20131112140033'), ('20131120193512'), ('20131123113417'), ('20131124071042'), ('20131125071042'), ('20131125101042'), ('20131126074753'), ('20131126205430'), ('20131127091624'), ('20131209095749'), ('20131209103450'), ('20131210182719'), ('20131218071042'), ('20140113110551'), ('20140123063641'), ('20140123071042'), ('20140124071042'), ('20140210114542'), ('20140213101042'), ('20140218174400'), ('20140219185200'), ('20140516182719'), ('20140624101042'), ('20140627071042'), ('20140704101043'), ('20140709071042'), ('20140714112346'), ('20140717101042'), ('20140718112346'), ('20140721112346'), ('20140729101042'), ('20140801071042'), ('20140819071042'), ('20140821105426'), ('20140827105426'), ('20140903105426'), ('20140903125426'), ('20140908125426'), ('20140908135426'), ('20140916135426'), ('20140930135426'), ('20141001135426'), ('20141002130128'), ('20141002130129'), ('20141002231042'), ('20141022105426'), ('20141022205426'), ('20141107135426'), ('20141110105426'), ('20141125105426'), ('20141201135426'), ('20141202135426'), ('20141208135426'), ('20150112135426'), ('20150127135426'), ('20150129135426'), ('20150129135427'), ('20150227063641'), ('20150623063641'), ('20150625105426'), ('20150630135426'), ('20150715112346'), ('20150716112346'), ('20150716124906'), ('20150807105426'), ('20150902130939'), ('20150903084813'), ('20150916084813'), ('20151030130011'), ('20160321085300'), ('20160321104000'), ('20160321105300'), ('20160518105300'), ('20160610105300'), ('20160808135426'), ('20160819105300'), ('20160824132643'), ('20161019231042'), ('20161025231042'), ('20161115094035'), ('20161117135426'), ('20161121162349'), ('20161122121211'), ('20161122123708'), ('20161123124803'), ('20161124133941'), ('20161124135426'), ('20161128115942'), ('20170103132257'), ('21'), ('22'), ('23'), ('24'), ('25'), ('26'), ('27'), ('28'), ('29'), ('3'), ('30'), ('31'), ('32'), ('33'), ('34'), ('35'), ('36'), ('37'), ('38'), ('39'), ('4'), ('40'), ('41'), ('42'), ('43'), ('44'), ('45'), ('46'), ('47'), ('48'), ('5'), ('6'), ('7'), ('8'), ('9');


0 comments on commit 6dbc195

Please sign in to comment.