mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix migration script
This commit is contained in:
parent
7bd1d8feb4
commit
c49c69f824
@ -57,7 +57,6 @@
|
|||||||
<index id="24" parent="6" name="sqlite_autoindex_api_tokens_1">
|
<index id="24" parent="6" name="sqlite_autoindex_api_tokens_1">
|
||||||
<NameSurrogate>1</NameSurrogate>
|
<NameSurrogate>1</NameSurrogate>
|
||||||
<ColNames>apiTokenId</ColNames>
|
<ColNames>apiTokenId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
<Unique>1</Unique>
|
<Unique>1</Unique>
|
||||||
</index>
|
</index>
|
||||||
<key id="25" parent="6">
|
<key id="25" parent="6">
|
||||||
@ -126,25 +125,20 @@
|
|||||||
<index id="37" parent="7" name="sqlite_autoindex_attributes_1">
|
<index id="37" parent="7" name="sqlite_autoindex_attributes_1">
|
||||||
<NameSurrogate>1</NameSurrogate>
|
<NameSurrogate>1</NameSurrogate>
|
||||||
<ColNames>attributeId</ColNames>
|
<ColNames>attributeId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
<Unique>1</Unique>
|
<Unique>1</Unique>
|
||||||
</index>
|
</index>
|
||||||
<index id="38" parent="7" name="IDX_attributes_noteId_index">
|
<index id="38" parent="7" name="IDX_attributes_noteId_index">
|
||||||
<ColNames>noteId</ColNames>
|
<ColNames>noteId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="39" parent="7" name="IDX_attributes_name_value">
|
<index id="39" parent="7" name="IDX_attributes_name_value">
|
||||||
<ColNames>name
|
<ColNames>name
|
||||||
value</ColNames>
|
value</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="40" parent="7" name="IDX_attributes_name_index">
|
<index id="40" parent="7" name="IDX_attributes_name_index">
|
||||||
<ColNames>name</ColNames>
|
<ColNames>name</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="41" parent="7" name="IDX_attributes_value_index">
|
<index id="41" parent="7" name="IDX_attributes_value_index">
|
||||||
<ColNames>value</ColNames>
|
<ColNames>value</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<key id="42" parent="7">
|
<key id="42" parent="7">
|
||||||
<ColNames>attributeId</ColNames>
|
<ColNames>attributeId</ColNames>
|
||||||
@ -206,21 +200,17 @@ value</ColNames>
|
|||||||
<index id="53" parent="8" name="sqlite_autoindex_branches_1">
|
<index id="53" parent="8" name="sqlite_autoindex_branches_1">
|
||||||
<NameSurrogate>1</NameSurrogate>
|
<NameSurrogate>1</NameSurrogate>
|
||||||
<ColNames>branchId</ColNames>
|
<ColNames>branchId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
<Unique>1</Unique>
|
<Unique>1</Unique>
|
||||||
</index>
|
</index>
|
||||||
<index id="54" parent="8" name="IDX_branches_noteId_parentNoteId">
|
<index id="54" parent="8" name="IDX_branches_noteId_parentNoteId">
|
||||||
<ColNames>noteId
|
<ColNames>noteId
|
||||||
parentNoteId</ColNames>
|
parentNoteId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="55" parent="8" name="IDX_branches_noteId">
|
<index id="55" parent="8" name="IDX_branches_noteId">
|
||||||
<ColNames>noteId</ColNames>
|
<ColNames>noteId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="56" parent="8" name="IDX_branches_parentNoteId">
|
<index id="56" parent="8" name="IDX_branches_parentNoteId">
|
||||||
<ColNames>parentNoteId</ColNames>
|
<ColNames>parentNoteId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<key id="57" parent="8">
|
<key id="57" parent="8">
|
||||||
<ColNames>branchId</ColNames>
|
<ColNames>branchId</ColNames>
|
||||||
@ -251,7 +241,6 @@ parentNoteId</ColNames>
|
|||||||
<index id="62" parent="9" name="sqlite_autoindex_note_contents_1">
|
<index id="62" parent="9" name="sqlite_autoindex_note_contents_1">
|
||||||
<NameSurrogate>1</NameSurrogate>
|
<NameSurrogate>1</NameSurrogate>
|
||||||
<ColNames>noteId</ColNames>
|
<ColNames>noteId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
<Unique>1</Unique>
|
<Unique>1</Unique>
|
||||||
</index>
|
</index>
|
||||||
<key id="63" parent="9">
|
<key id="63" parent="9">
|
||||||
@ -282,7 +271,6 @@ parentNoteId</ColNames>
|
|||||||
<index id="68" parent="10" name="sqlite_autoindex_note_revision_contents_1">
|
<index id="68" parent="10" name="sqlite_autoindex_note_revision_contents_1">
|
||||||
<NameSurrogate>1</NameSurrogate>
|
<NameSurrogate>1</NameSurrogate>
|
||||||
<ColNames>noteRevisionId</ColNames>
|
<ColNames>noteRevisionId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
<Unique>1</Unique>
|
<Unique>1</Unique>
|
||||||
</index>
|
</index>
|
||||||
<key id="69" parent="10">
|
<key id="69" parent="10">
|
||||||
@ -367,28 +355,22 @@ parentNoteId</ColNames>
|
|||||||
<index id="84" parent="11" name="sqlite_autoindex_note_revisions_1">
|
<index id="84" parent="11" name="sqlite_autoindex_note_revisions_1">
|
||||||
<NameSurrogate>1</NameSurrogate>
|
<NameSurrogate>1</NameSurrogate>
|
||||||
<ColNames>noteRevisionId</ColNames>
|
<ColNames>noteRevisionId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
<Unique>1</Unique>
|
<Unique>1</Unique>
|
||||||
</index>
|
</index>
|
||||||
<index id="85" parent="11" name="IDX_note_revisions_noteId">
|
<index id="85" parent="11" name="IDX_note_revisions_noteId">
|
||||||
<ColNames>noteId</ColNames>
|
<ColNames>noteId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="86" parent="11" name="IDX_note_revisions_utcDateLastEdited">
|
<index id="86" parent="11" name="IDX_note_revisions_utcDateLastEdited">
|
||||||
<ColNames>utcDateLastEdited</ColNames>
|
<ColNames>utcDateLastEdited</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="87" parent="11" name="IDX_note_revisions_utcDateCreated">
|
<index id="87" parent="11" name="IDX_note_revisions_utcDateCreated">
|
||||||
<ColNames>utcDateCreated</ColNames>
|
<ColNames>utcDateCreated</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="88" parent="11" name="IDX_note_revisions_dateLastEdited">
|
<index id="88" parent="11" name="IDX_note_revisions_dateLastEdited">
|
||||||
<ColNames>dateLastEdited</ColNames>
|
<ColNames>dateLastEdited</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="89" parent="11" name="IDX_note_revisions_dateCreated">
|
<index id="89" parent="11" name="IDX_note_revisions_dateCreated">
|
||||||
<ColNames>dateCreated</ColNames>
|
<ColNames>dateCreated</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<key id="90" parent="11">
|
<key id="90" parent="11">
|
||||||
<ColNames>noteRevisionId</ColNames>
|
<ColNames>noteRevisionId</ColNames>
|
||||||
@ -470,36 +452,28 @@ parentNoteId</ColNames>
|
|||||||
<index id="104" parent="12" name="sqlite_autoindex_notes_1">
|
<index id="104" parent="12" name="sqlite_autoindex_notes_1">
|
||||||
<NameSurrogate>1</NameSurrogate>
|
<NameSurrogate>1</NameSurrogate>
|
||||||
<ColNames>noteId</ColNames>
|
<ColNames>noteId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
<Unique>1</Unique>
|
<Unique>1</Unique>
|
||||||
</index>
|
</index>
|
||||||
<index id="105" parent="12" name="IDX_notes_title">
|
<index id="105" parent="12" name="IDX_notes_title">
|
||||||
<ColNames>title</ColNames>
|
<ColNames>title</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="106" parent="12" name="IDX_notes_type">
|
<index id="106" parent="12" name="IDX_notes_type">
|
||||||
<ColNames>type</ColNames>
|
<ColNames>type</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="107" parent="12" name="IDX_notes_isDeleted">
|
<index id="107" parent="12" name="IDX_notes_isDeleted">
|
||||||
<ColNames>isDeleted</ColNames>
|
<ColNames>isDeleted</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="108" parent="12" name="IDX_notes_dateCreated">
|
<index id="108" parent="12" name="IDX_notes_dateCreated">
|
||||||
<ColNames>dateCreated</ColNames>
|
<ColNames>dateCreated</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="109" parent="12" name="IDX_notes_dateModified">
|
<index id="109" parent="12" name="IDX_notes_dateModified">
|
||||||
<ColNames>dateModified</ColNames>
|
<ColNames>dateModified</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="110" parent="12" name="IDX_notes_utcDateCreated">
|
<index id="110" parent="12" name="IDX_notes_utcDateCreated">
|
||||||
<ColNames>utcDateCreated</ColNames>
|
<ColNames>utcDateCreated</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<index id="111" parent="12" name="IDX_notes_utcDateModified">
|
<index id="111" parent="12" name="IDX_notes_utcDateModified">
|
||||||
<ColNames>utcDateModified</ColNames>
|
<ColNames>utcDateModified</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<key id="112" parent="12">
|
<key id="112" parent="12">
|
||||||
<ColNames>noteId</ColNames>
|
<ColNames>noteId</ColNames>
|
||||||
@ -540,7 +514,6 @@ parentNoteId</ColNames>
|
|||||||
<index id="119" parent="13" name="sqlite_autoindex_options_1">
|
<index id="119" parent="13" name="sqlite_autoindex_options_1">
|
||||||
<NameSurrogate>1</NameSurrogate>
|
<NameSurrogate>1</NameSurrogate>
|
||||||
<ColNames>name</ColNames>
|
<ColNames>name</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
<Unique>1</Unique>
|
<Unique>1</Unique>
|
||||||
</index>
|
</index>
|
||||||
<key id="120" parent="13">
|
<key id="120" parent="13">
|
||||||
@ -576,7 +549,6 @@ parentNoteId</ColNames>
|
|||||||
<index id="126" parent="14" name="sqlite_autoindex_recent_notes_1">
|
<index id="126" parent="14" name="sqlite_autoindex_recent_notes_1">
|
||||||
<NameSurrogate>1</NameSurrogate>
|
<NameSurrogate>1</NameSurrogate>
|
||||||
<ColNames>noteId</ColNames>
|
<ColNames>noteId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
<Unique>1</Unique>
|
<Unique>1</Unique>
|
||||||
</index>
|
</index>
|
||||||
<key id="127" parent="14">
|
<key id="127" parent="14">
|
||||||
@ -597,7 +569,6 @@ parentNoteId</ColNames>
|
|||||||
<index id="130" parent="15" name="sqlite_autoindex_source_ids_1">
|
<index id="130" parent="15" name="sqlite_autoindex_source_ids_1">
|
||||||
<NameSurrogate>1</NameSurrogate>
|
<NameSurrogate>1</NameSurrogate>
|
||||||
<ColNames>sourceId</ColNames>
|
<ColNames>sourceId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
<Unique>1</Unique>
|
<Unique>1</Unique>
|
||||||
</index>
|
</index>
|
||||||
<key id="131" parent="15">
|
<key id="131" parent="15">
|
||||||
@ -660,12 +631,10 @@ parentNoteId</ColNames>
|
|||||||
<index id="144" parent="18" name="IDX_sync_entityName_entityId">
|
<index id="144" parent="18" name="IDX_sync_entityName_entityId">
|
||||||
<ColNames>entityName
|
<ColNames>entityName
|
||||||
entityId</ColNames>
|
entityId</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
<Unique>1</Unique>
|
<Unique>1</Unique>
|
||||||
</index>
|
</index>
|
||||||
<index id="145" parent="18" name="IDX_sync_utcSyncDate">
|
<index id="145" parent="18" name="IDX_sync_utcSyncDate">
|
||||||
<ColNames>utcSyncDate</ColNames>
|
<ColNames>utcSyncDate</ColNames>
|
||||||
<ColumnCollations></ColumnCollations>
|
|
||||||
</index>
|
</index>
|
||||||
<key id="146" parent="18">
|
<key id="146" parent="18">
|
||||||
<ColNames>id</ColNames>
|
<ColNames>id</ColNames>
|
||||||
|
@ -20,7 +20,7 @@ DROP TABLE notes;
|
|||||||
ALTER TABLE notes_mig RENAME TO notes;
|
ALTER TABLE notes_mig RENAME TO notes;
|
||||||
|
|
||||||
UPDATE notes SET isErased = 1 WHERE isDeleted = 1
|
UPDATE notes SET isErased = 1 WHERE isDeleted = 1
|
||||||
AND 1=(SELECT CASE content WHEN NULL THEN 1 ELSE 0 END FROM note_contents WHERE note_contents.noteId = notes.noteId);
|
AND 1=(SELECT CASE WHEN content IS NULL THEN 1 ELSE 0 END FROM note_contents WHERE note_contents.noteId = notes.noteId);
|
||||||
|
|
||||||
CREATE INDEX `IDX_notes_isDeleted` ON `notes` (`isDeleted`);
|
CREATE INDEX `IDX_notes_isDeleted` ON `notes` (`isDeleted`);
|
||||||
CREATE INDEX `IDX_notes_title` ON `notes` (`title`);
|
CREATE INDEX `IDX_notes_title` ON `notes` (`title`);
|
||||||
|
@ -32,12 +32,17 @@ async function findAndFixIssues(query, fixerCb) {
|
|||||||
for (const res of results) {
|
for (const res of results) {
|
||||||
const autoFix = await optionsService.getOptionBool('autoFixConsistencyIssues');
|
const autoFix = await optionsService.getOptionBool('autoFixConsistencyIssues');
|
||||||
|
|
||||||
await fixerCb(res, autoFix);
|
try {
|
||||||
|
await fixerCb(res, autoFix);
|
||||||
|
|
||||||
if (autoFix) {
|
if (autoFix) {
|
||||||
fixedIssues = true;
|
fixedIssues = true;
|
||||||
|
} else {
|
||||||
|
unrecoveredConsistencyErrors = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
catch (e) {
|
||||||
|
logError(`Fixer failed with ${e.message} ${e.stack}`);
|
||||||
unrecoveredConsistencyErrors = true;
|
unrecoveredConsistencyErrors = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user