mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 11:39:01 +01:00 
			
		
		
		
	removed id from notes_history, new primary key is note_history_id
This commit is contained in:
		
							parent
							
								
									9e3515b122
								
							
						
					
					
						commit
						40e27cd6f7
					
				
							
								
								
									
										27
									
								
								migrations/0023__remove_id_from_note_history.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								migrations/0023__remove_id_from_note_history.sql
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | ||||
| CREATE TABLE `notes_history_mig` ( | ||||
| 	`note_history_id`	TEXT NOT NULL PRIMARY KEY, | ||||
| 	`note_id`	TEXT NOT NULL, | ||||
| 	`note_title`	TEXT, | ||||
| 	`note_text`	TEXT, | ||||
| 	`encryption`	INT, | ||||
| 	`date_modified_from` INT, | ||||
| 	`date_modified_to` INT | ||||
| ); | ||||
| 
 | ||||
| INSERT INTO notes_history_mig (note_history_id, note_id, note_title, note_text, encryption, date_modified_from, date_modified_to) | ||||
|     SELECT note_history_id, note_id, note_title, note_text, encryption, date_modified_from, date_modified_to FROM notes_history; | ||||
| 
 | ||||
| DROP TABLE notes_history; | ||||
| ALTER TABLE notes_history_mig RENAME TO notes_history; | ||||
| 
 | ||||
| CREATE INDEX `IDX_notes_history_note_id` ON `notes_history` ( | ||||
| 	`note_id` | ||||
| ); | ||||
| 
 | ||||
| CREATE INDEX `IDX_notes_history_note_date_modified_from` ON `notes_history` ( | ||||
| 	`date_modified_from` | ||||
| ); | ||||
| 
 | ||||
| CREATE INDEX `IDX_notes_history_note_date_modified_to` ON `notes_history` ( | ||||
| 	`date_modified_to` | ||||
| ); | ||||
| @ -3,7 +3,7 @@ const sql = require('./sql'); | ||||
| const fs = require('fs-extra'); | ||||
| const log = require('./log'); | ||||
| 
 | ||||
| const APP_DB_VERSION = 22; | ||||
| const APP_DB_VERSION = 23; | ||||
| const MIGRATIONS_DIR = "./migrations"; | ||||
| 
 | ||||
| async function migrate() { | ||||
|  | ||||
| @ -285,8 +285,6 @@ async function updateNoteHistory(entity, sourceId, syncLog) { | ||||
| 
 | ||||
|     if (orig === null || orig.date_modified_to < entity.date_modified_to) { | ||||
|         await sql.doInTransaction(async () => { | ||||
|             delete entity['id']; | ||||
| 
 | ||||
|             await sql.replace('notes_history', entity); | ||||
| 
 | ||||
|             await sql.addNoteHistorySync(entity.note_history_id, sourceId); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner