/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to shamap.py

Add extra constraints in sqlite tables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
175
175
            self.db = mapdbs()[path]
176
176
        self.db.text_factory = str
177
177
        self.db.executescript("""
178
 
        create table if not exists commits(sha1 text, revid text, tree_sha text);
 
178
        create table if not exists commits(
 
179
            sha1 text not null check(length(sha1) == 40),
 
180
            revid text not null,
 
181
            tree_sha text not null check(length(tree_sha) == 40)
 
182
        );
179
183
        create index if not exists commit_sha1 on commits(sha1);
180
184
        create unique index if not exists commit_revid on commits(revid);
181
 
        create table if not exists blobs(sha1 text, fileid text, revid text);
 
185
        create table if not exists blobs(
 
186
            sha1 text not null check(length(sha1) == 40),
 
187
            fileid text not null,
 
188
            revid text not null
 
189
        );
182
190
        create index if not exists blobs_sha1 on blobs(sha1);
183
191
        create unique index if not exists blobs_fileid_revid on blobs(fileid, revid);
184
 
        create table if not exists trees(sha1 text, fileid text, revid text);
 
192
        create table if not exists trees(
 
193
            sha1 text not null check(length(sha1) == 40),
 
194
            fileid text not null,
 
195
            revid text not null
 
196
        );
185
197
        create index if not exists trees_sha1 on trees(sha1);
186
198
        create unique index if not exists trees_fileid_revid on trees(fileid, revid);
187
199
""")