Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / 2012_08.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4 <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <meta name="generator" content="Movable Type 5.2.3" />
7
8    <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
9    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://defaria.com/blogs/Status/atom.xml" />
10    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://defaria.com/blogs/Status/index.xml"$>" />
11
12    <title>Status for Andrew DeFaria: August 2012 Archives</title>
13
14    <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
15    <link rel="prev" href="http://defaria.com/blogs/Status/archives/2012_05.html" title="May 2012" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/2012_09.html" title="September 2012" />
17 </head>
18 <body class="layout-one-column">
19    <div id="container">
20       <div id="container-inner" class="pkg">
21
22          <div id="banner">
23             <div id="banner-inner" class="pkg">
24                <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
25                <h2 id="banner-description">Searchable status reports and work log</h2>
26             </div>
27          </div>
28
29          <div id="pagebody">
30             <div id="pagebody-inner" class="pkg">
31                <div id="alpha">
32                   <div id="alpha-inner" class="pkg">
33                      
34                      <p class="content-nav">
35                         <a href="http://defaria.com/blogs/Status/archives/2012_05.html">&laquo; May 2012</a> |
36                         <a href="http://defaria.com/blogs/Status/">Main</a>
37                         | <a href="http://defaria.com/blogs/Status/archives/2012_09.html">September 2012 &raquo;</a>
38                      </p>
39                      
40                      
41                      <!--
42 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
43          xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"
44          xmlns:dc="http://purl.org/dc/elements/1.1/">
45 <rdf:Description
46     rdf:about="http://defaria.com/blogs/Status/archives/2012_08.html#entry-000755"
47     trackback:ping="http://defaria.com/mt/mt-tb.cgi/119"
48     dc:title="Creating a Development Schema"
49     dc:identifier="http://defaria.com/blogs/Status/archives/2012_08.html#entry-000755"
50     dc:subject="Broadcom"
51     dc:description="Creating a dev schema is not that difficult. Note you can create a dev schema in the production schema repo or in a dev schema repo. The later is a just a bit safer as it is a bit more..."
52     dc:creator=""
53     dc:date="2012-08-29T21:08:12-06:00" />
54 </rdf:RDF>
55 -->
56
57
58                      <h2 class="date-header">August 29, 2012</h2>
59                      <a id="a000755"></a>
60                      <div class="entry" id="entry-755">
61                         <h3 class="entry-header">Creating a Development Schema</h3>
62                         <div class="entry-content">
63                            <div class="entry-body">
64                               <p>Creating a dev schema is not that difficult. Note you can create a dev schema in the production schema repo or in a dev schema repo. The later is a just a bit safer as it is a bit more isolated.</p>
65
66 <p>To create a dev schema from the CQ Designer, right click on the schema repo and select <b>New: Schema</b>. We are creating a new schema by basing it off of an existing schema. Expand the + sign and select the version that you wish to base your new schema off of. Right now there is only Version 1. Select next and name your schema. I suggest that you use your username (e.g. adefaria) indicating that we are the owner of this dev schema. Enter comments if you like and then <b>Finish</b>.</p>
67
68 <p>After the schema is created it will ask you if you want to associate this with a database. You could select <b>Yes</b> and then go though naming your database and connecting it to an existing user database but chances are you don't have one of those yet. So select <b>No</b> for now. You now have a development schema.</p>
69
70 <h3>Creating a Test Database</h3>
71
72 <p>You must create an empty database on the database server. Use RDP to get a remote desktop there and run the SQL Server Management Studio and connect to the database server engine.</p>
73
74 <p>Next right click on databases and select New Database. Name your database. The convention for test databases is &lt;schemaname&gt;_&lt;id&gt;. For our personal test databases again I'd suggest using your user ID so I will create &lt;schemaname&gt;_adefaria for me.</p>
75
76 <h3>Setting the db_owner and schema owner</h3>
77
78 <p>In MSSQL we need to set the dbowner and the schema for this new database. Expand the folder tree (+) on your newly created database (MobDev_adefaria) then right click on Security and select New: User. Type &lt;dbadmin&gt; in the User Name edit box and then select and copy this string. We'll need it several times more in this process. Paste this into the Login name and Default Schema and then toggle on db_owner in both the Schemas owned by this user and Database role membership boxes then select OK.</p>
79
80 <p>Next right click on Security again and select <b>New: Schema</b>. Paste &lt;dbadmin&gt; into Schema Name and Schema Owner and click OK.</p>
81
82 <p>Now you have an empty database that you can associate with your schema.</p>
83
84 <h3>Associating your new test database with your dev schema</h3>
85
86 <p>Go back to CQ Designer and right click on your development schema again and select <b>Show: User Databases</b>. You should see a list of databases. Right click on an empty area and select <b>Create Database</b>. Seems odd to call it create database when the database has already been created - it really means "take this schema and it's definition of what should be in the user database and apply that definition/schema to my newly created empty database".</p>
87
88 <p>Give this database a Logical Database Name. Alas we only have 5 characters. I just use my initials - apd - short and simple. Add comments if you like. We use MSSQL for the database vendor. Then toggle Database Type to Test Database. We already have a production database in our dev schema repo then select next.</p>
89
90 <p>Now we fill in Physical Database Name with the name of the database (&lt;schemaname&gt;_adefaria) and the Database Server . Then paste that &lt;dbadmin&gt; into Administrator User and Administrator Password (See I told you you'd need it!) then Next and Next again.</p>
91
92 <p>Now we need to expand the adefaria (your dev schema) and select which version you want this new test database to start with. Select Version 1 and Finish.</p>
93
94 <p>Clearquest Designer now goes out and creates all the necessary tables and transfers all of the necessary data, hook scripts, etc. from Version 1 of the dev schema adefaria into your database. Get coffee...</p>
95
96 <p>After the database is created follow the steps at Seeding a test database to seed your test database with some test data.</p>
97                               
98                               <p class="entry-footer">
99                                  <span class="post-footers">Posted by  at  9:08 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000755.html">Permalink</a>
100                                  
101                                  | <a href="http://defaria.com/blogs/Status/archives/000755.html#trackback">TrackBacks (0)</a>
102                               </p>
103                            </div>
104                         </div>
105                      </div>
106                      
107                      <!--
108 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
109          xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"
110          xmlns:dc="http://purl.org/dc/elements/1.1/">
111 <rdf:Description
112     rdf:about="http://defaria.com/blogs/Status/archives/2012_08.html#entry-000754"
113     trackback:ping="http://defaria.com/mt/mt-tb.cgi/118"
114     dc:title="Creating Development Schema Repositories"
115     dc:identifier="http://defaria.com/blogs/Status/archives/2012_08.html#entry-000754"
116     dc:subject="Broadcom"
117     dc:description=" When you have multiple Clearquest Designers you quickly realize that you cannot easily do parallel development of the schema. The best way to do this is to work through a development schema repository and to create development schemas for..."
118     dc:creator=""
119     dc:date="2012-08-28T14:41:42-06:00" />
120 </rdf:RDF>
121 -->
122
123
124                      <h2 class="date-header">August 28, 2012</h2>
125                      <a id="a000754"></a>
126                      <div class="entry" id="entry-754">
127                         <h3 class="entry-header">Creating Development Schema Repositories</h3>
128                         <div class="entry-content">
129                            <div class="entry-body">
130                                           <p>When you have multiple Clearquest Designers you quickly realize that you cannot easily do parallel development of the schema. The best way to do this is to work through a development schema repository and to create development schemas for each schema designer. To create a development schema repository you should first create an empty database for Clearquest to work in. You can create an empty database by following the instructions for&nbsp;<span class="nobr"><a href="http://confluence.broadcom.com/display/MWGMPSSCM/Creating+a+Development+Schema#CreatingaDevelopmentSchema-CreatingaTestDatbase" class="external-link" rel="nofollow">Creating a Test Database</a>. Next you must use the Clearquest Maintenance Tool to create a new Schema Repository:</p>
131
132 <ul>
133   <li>Start the Clearquest Maintenance Tool</li>
134   <li>Select <b>Schema Respository: Create</b></li>
135   <li>The Maintenance Tool then asks you to fill out information regarding the location of your schema database. Fill in information about the database server and Administrator Name and password. Do not create a sample database at this time. The Clearquest Maintenance tool will take some time to set up the new schema repository.</li>
136 </ul>
137
138 <h3><a name="CreatingDevelopmentSchemaRepositories-ExportingaCQProfile.iniforthisnewDevelopmentSchemaRepository"></a>Exporting a CQProfile.ini for this new Development Schema Repository</h3>
139
140 <p>In order to see this new development schema repository you should export the schema repository from the Clearquest&nbsp;Maintenance&nbsp;Tool. This exported cqprofile.ini can be shared with out Schema Developers who would import the .ini file into their environment using the Clearquest Maintenance Tool. You export the cqprofile.ini by selecting&nbsp;<b>File: Export Profile</b>. You need only select the new repository you created.</p>
141
142 <p><img src="images/Export cqprofile.png"></p>
143
144 <p>Click on the "..." button to select where to store the .ini file and what it's name will be - I used C:\Cygwin\tmp\MPSDev.ini and click&nbsp;<b>Finish</b>. This file can be passed to your fellow Schema Developers.</p>
145
146 <h3><a name="CreatingDevelopmentSchemaRepositories-ImportingUsers"></a>Importing Users</h3>
147
148 <p>Your new development schema repo has no users in it except a default set of users including the "admin" user (with no password). Run the User Administration tool on production (MCBU) and export all of the users. Run the User Administration tool again on the new development schema repo (e.g. MPSDev) and import the users.</p>
149
150 <h3><a name="CreatingDevelopmentSchemaRepositories-CleanupUnnecessarySchemas"></a>Clean up Unnecessary Schemas</h3>
151
152 <p>Now's a good time to remove additional default schemas in your development schema repo like Common, DefectTracking, Enterprise, etc. You cannot delete the Blank schema.</p>
153
154 <h3><a name="CreatingDevelopmentSchemaRepositories-SeedingtheDevelopmentSchemaRepowiththeLatestVersionfromProduction"></a>Seeding the Development Schema Repo with the Latest Version from Production</h3>
155
156 <p>One trick to seed your new development schema repo with a recent version of the production schema is to create a new development schema in the production schema repo based off of the latest version of the production schema. Then export that whole schema of the <b>new</b> development schema and import it into the new development schema repo. You will only have the history of the latest version of the schema but that's OK for development purpose. Make sure you specify an appropriate Schema Name and Comment when you export the schema from production:</p>
157
158 <p><img src="images/New Schema.png"></p>
159
160 <p><b>Note:</b>&nbsp;We are giving this schema the name MPSDev because that's what we want it to be called in the new development schema repo. Also, the comment is appropriate when we will be looking at it in the MPSDev development schema repo.</p>
161
162 <p>Do not associate a database with this schema, there's no reason. We don't care as we are only using this to exportschema from production &#45;&gt; development schema repo. We'll create databases there. We don't need to check out this schema either.</p>
163
164 <h4><a name="CreatingDevelopmentSchemaRepositories-ExportingtheSchemafromProduction"></a>Exporting the Schema from Production</h4>
165
166 <p>We assume you have created a new development schema in the production schema repo based off of the tip of the production database. You need to export that with:</p>
167
168 <div class="code" >$ cqload exportschema -dbset MCBU admin &lt;password&gt; &lt;schemaname&gt; &lt;path to &lt;schemaname&gt;.full.schema&gt;]]>
169 </div>
170
171 <p>Where &lt;schemaname&gt; is the name of the development schema name you created in the production schema repo</p>
172
173 <h4><a name="CreatingDevelopmentSchemaRepositories-ImportingtheSchemaintotheDevelopmentSchemaRepo"></a>Importing the Schema into the Development Schema Repo</h4>
174
175 <p>Next we import this full.schema of only the tip of production to seed a development schema in the development schema repo.</p>
176
177 <p><div class="code">$ cqload importschema -dbset MPSDev admin &lt;password&gt; &lt;path to &lt;schemaname&gt;.full.schema&gt;
178 *********************************************************
179 Starting importschema
180 *********************************************************
181
182 CRMMD1264E The import file ".\MPSDev.full.schema" is invalid:
183 CRMMD1422E The schema requires the following package(s), which is(are) not currently installed in the database...
184     revision '2.1' of package 'EmailPlus'
185     revision '1.2' of package 'Resolution'
186     revision '2.1' of package 'Attachments'.
187
188 *********************************************************
189 ERROR: importschema FAILED!
190 *********************************************************
191 </div>
192
193 <p>Oops! We need to import these packages into our new schema. Right click on your new development schema repo in Clearquest Designer and select <b>Install Package</b>. Expand the EmailPlus and select 2.1 to install that. Repeat this for Resolution and Attachments. Repeat the cqload importschema.</p>
194
195 <h4><a name="CreatingDevelopmentSchemaRepositories-RemoveOldSchemainProductionRepo"></a>Remove Old Schema in Production Repo</h4>
196
197 <p>You can remove the schema you created above in the Production repo as it is no longer needed.</p>
198
199 <h3><a name="CreatingDevelopmentSchemaRepositories-CreateDevSchemas"></a>Create Dev Schemas</h3>
200
201 <p>You are now free to create development schemas in the new development schema repo as described&nbsp;<a href="/display/MWGMPSSCM/Creating+a+Development+Schema" title="Creating a Development Schema">Creating a Development Schema</a>&nbsp;as well as test databases and <a href="/display/MWGMPSSCM/Seeding+a+Test+Database" title="Seeding a Test Database">seeding them</a>.</p>
202                               
203                               <p class="entry-footer">
204                                  <span class="post-footers">Posted by  at  2:41 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000754.html">Permalink</a>
205                                  
206                                  | <a href="http://defaria.com/blogs/Status/archives/000754.html#trackback">TrackBacks (0)</a>
207                               </p>
208                            </div>
209                         </div>
210                      </div>
211                      
212                      <!--
213 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
214          xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"
215          xmlns:dc="http://purl.org/dc/elements/1.1/">
216 <rdf:Description
217     rdf:about="http://defaria.com/blogs/Status/archives/2012_08.html#entry-000753"
218     trackback:ping="http://defaria.com/mt/mt-tb.cgi/117"
219     dc:title="Eliminating Perl Syntactic Sugar"
220     dc:identifier="http://defaria.com/blogs/Status/archives/2012_08.html#entry-000753"
221     dc:subject=""
222     dc:description="Programming complex systems is... well... complicated. You need to focus on the task at hand and be able to see the trees from the forest as they say. That&apos;s why I like to eliminate as much what I call syntactic..."
223     dc:creator=""
224     dc:date="2012-08-02T20:13:44-06:00" />
225 </rdf:RDF>
226 -->
227
228
229                      <h2 class="date-header">August  2, 2012</h2>
230                      <a id="a000753"></a>
231                      <div class="entry" id="entry-753">
232                         <h3 class="entry-header">Eliminating Perl Syntactic Sugar</h3>
233                         <div class="entry-content">
234                            <div class="entry-body">
235                               <p>Programming complex systems is... well... complicated. You need to focus on the task at hand and be able to see the trees from the forest as they say. That's why I like to eliminate as much what I call syntactic sugar from the language. Syntactic sugar are ornaments, special characters and restating the obvious or default that makes your mind drift from the problem at hand to how to formulate syntactic sugar. Additionally such sugar takes time to type in, is prone to errors if you don't get it right and usually are comprised of characters that, as a touch typist, you have to often stretch to reach on the keyboard.</p>
236
237 <p>Here's an example. Recently I came across the following code:</p>
238
239 <div class="code">
240     delete($self->{'cqc'}->{'fields'}->{'PCP_ID'}) if (exists $self->{'cqc'}->{'fields'}->{'PCP_ID'}); # PCP_ID  is read-only and should not be passed through.<br>
241     delete($self->{'cqc'}->{'fields'}->{'Approved_by_CCB'}) if (exists $self->{'cqc'}->{'fields'}->{'Approved_by_CCB'});<br>
242     delete($self->{'cqc'}->{'fields'}->{'record_type'}) if (exists $self->{'cqc'}->{'fields'}->{'record_type'});<br>
243 </div>
244
245 <p>Now that takes a some time to parse... (Did you see the comment buried in there?) And here's the same code with the syntactic sugar removed:</p>
246
247 <div class="code">
248     delete $self->{cqc}{fields}{PCP_ID};<br>
249     delete $self->{cqc}{fields}{Approved_by_CCB};<br>
250     delete $self->{cqc}{fields}{record_type};<br>
251 </div>
252
253 <p>which do you find easier to read?</p>
254
255 <p><b>Notes:</b></p>
256
257 <ul>
258   <li> Surrounding hash keys with '' is unnecessary unless you use special characters in the key name like spaces and '-'. The '_' character is OK (the Perl interpreter views '-' as a possible subtraction). Use '' for hash keys only when necessary.</li>
259
260   <li>The additional '->' operators are unnecessary. The first one is necessary since $self is a hashref, but after that you don't need them - why type them?</li>
261
262   <li>The delete call need not have (). Granted, delete is a function and some people field all function should have () even if there are no parameters. And yet even people who feel this way rarely use () on Perl builtins like print and die. If you define your subroutines before they are used you can call them without ().</li>
263
264   <li>There's no reason to include "if (exists $self->{'cqc'}->{'fields'}->{'PCP_ID'})". First off, if clauses that follow the statement do not need (). Even "exists" is unnecessary as if it is omitted the if statement works the same anyway. Finally, delete $hashref->{unknown} will not error out if $hashref->{unknown} doesn't exist.</li>
265 </ul>
266                               
267                               <p class="entry-footer">
268                                  <span class="post-footers">Posted by  at  8:13 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000753.html">Permalink</a>
269                                  
270                                  | <a href="http://defaria.com/blogs/Status/archives/000753.html#trackback">TrackBacks (0)</a>
271                               </p>
272                            </div>
273                         </div>
274                      </div>
275                      
276                   </div>
277                </div>
278             </div>
279          </div>
280       </div>
281    </div>
282 </body>
283 </html>