AWG Blogs

Wednesday, May 31, 2017

Creating a multi-column constraint where one column has nulls

To create a multi-column unique constraint on a table where the new column will have nulls initially
need to ensure that the index associated with the unique constraint is non-unique. This can be done
using 'DEFERRABLE' in the constraint command or by creating a non-unique index first and
referring to it with a USING INDEX __ in the constraint command:

select name from v$database;

Alter table MYSCHEMA.MY_TABLE add MY_COLUMN  varchar2(250);

comment on column MY_TABLE.MY_COLUMN is 'a column description';

ALTER TABLE MYSCHEMA.MY_TABLE ADD CONSTRAINT XYZ1_MY_TABLE UNIQUE (ANOTHER_COLUMN, MY_COLUMN) DEFERRABLE NOVALIDATE;

commit;

-- ROLLBACK
(paste the below rollback commands in sql developer worksheet run as script and click commit)
ALTER TABLE MYSCHEMA.MY_TABLE DROP CONSTRAINT XYZ1_MY_TABLE;

Alter table MYSCHEMA.MY_TABLE drop column MY_COLUMN;

--verify column, constraint and associated index is deleted:
select index_name,index_type, uniqueness, visibility from dba_indexes where table_name='MY_TABLE' order by index_name;

select * from dba_constraints where table_name='MY_TABLE';


Sunday, April 23, 2017

Git rebase interactive to move feature to release

The scenario was similar to http://stackoverflow.com/questions/6594881/git-merge-only-the-changes-made-on-the-branch?noredirect=1&lq=1
where dev/master was in the middle, getting merged into continuously be various teams and their feature branches. Periodically a release branch is created and devs are stuck with the dilemma of having to merge a feature branch into both dev and release.

          A release1
         /
    D---E---F---G development
            \
             H---I---J feature_for_release1

So, as a proof of concept what I have done is show how feature_for_release1 could be attached onto release1 without including F.

I first created a staging branch off release1:

 MINGW64 /c/Work/testing/my_try_git (release1)
$ git checkout -b stage-release1-feature
Switched to a new branch 'stage-release1-feature'

Then merged in feature-for-release1:
 git merge feature-for-release1

At this point I printed the log and did a rebase interactive:
 MINGW64 /c/Work/testing/my_try_git (stage-release1-feature)
$  git log --pretty=oneline --graph
* 14b50fed8999aa785e7333a239b532c3f1fe11e0 file added for release1
* b6a8a66b8bd64de49b666d0e627e68de76747ac4 files changed for release1
*   e3ee2edbbfbb2ef629170309d5e35cad6181f4d6 Merge pull request #1 from awgtek/feature-for-release2
|\
| * cd091e9f75d8580c34c9a73c0f30aef616816a7f adding changes for release 2
|/
* eb95ed7111130064272be69957644223212d9981 Remove 322
* fde83b085873139a22cef07f069b46e98eeb0fe9 asdflkasjf;dsak
* 7a5797b379afca819f1e5a92bc122e41bbed52ab add all the octa t filesfrom2
* 05d0d336001842e6b4fec2206e6616363b8d9dbe adding redoctober
* 485cdfcd1fdcd5106518a9f19406a1243c91c555 add all the octocat txt files
* 81d5a2cb15e40752c8bf7aba7ffde6728ebfbdb6 add cute octaot story

MINGW64 /c/Work/testing/my_try_git (stage-release1-feature)
$ git rebase -i  eb95ed7111130064272be69957644223212d9981
In the editor was shown:

As can be seen, I am rebasing to eb95ed which corresponds to point E on the above diagram. I am also dropping cd091e9 from the replaying of this sequence of commits (top to bottom) onto the staging branch which is being rebased to the point just before eb95ed.

When I saved the file, it got an error:

error: could not apply b6a8a66... files changed for release1

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
Could not apply b6a8a66b8bd64de49b666d0e627e68de76747ac4... files changed for release1

This was because one of the files committed in the dropped commit was also changed in a subsequent kept commit. So I had to edit the offending file remove all the merge conflicts, do a git add, and a git rebase --continue. After which the rebase was completed.

 MINGW64 /c/Work/testing/my_try_git (stage-release1-feature)
$  git log --pretty=oneline --graph
* 752d1871b4e8632a1daf8fe7579884f08dfa0b17 file added for release1
* faa4e3ba142bc00015bdba7c2988e02319cbfaab files changed for release1
* eb95ed7111130064272be69957644223212d9981 Remove 322
* fde83b085873139a22cef07f069b46e98eeb0fe9 asdflkasjf;dsak
* 7a5797b379afca819f1e5a92bc122e41bbed52ab add all the octa t filesfrom2
* 05d0d336001842e6b4fec2206e6616363b8d9dbe adding redoctober
* 485cdfcd1fdcd5106518a9f19406a1243c91c555 add all the octocat txt files
* 81d5a2cb15e40752c8bf7aba7ffde6728ebfbdb6 add cute octaot story

I could  then push stage-release1-feature to github and merge it into release. see here.