Rearrange upgraders in ascending order.
This commit is contained in:
		
							parent
							
								
									bacdad07a6
								
							
						
					
					
						commit
						6919f39e81
					
				
					 1 changed files with 38 additions and 38 deletions
				
			
		|  | @ -5,6 +5,44 @@ import sys | ||||||
| 
 | 
 | ||||||
| import ycdl | import ycdl | ||||||
| 
 | 
 | ||||||
|  | def upgrade_1_to_2(sql): | ||||||
|  |     ''' | ||||||
|  |     In this version, the duration column was added. | ||||||
|  |     ''' | ||||||
|  |     cur = sql.cursor() | ||||||
|  |     cur.executescript(''' | ||||||
|  |         ALTER TABLE videos RENAME TO videos_old; | ||||||
|  |         CREATE TABLE videos( | ||||||
|  |             id TEXT, | ||||||
|  |             published INT, | ||||||
|  |             author_id TEXT, | ||||||
|  |             title TEXT, | ||||||
|  |             description TEXT, | ||||||
|  |             duration INT, | ||||||
|  |             thumbnail TEXT, | ||||||
|  |             download TEXT | ||||||
|  |         ); | ||||||
|  |         INSERT INTO videos SELECT | ||||||
|  |             id, | ||||||
|  |             published, | ||||||
|  |             author_id, | ||||||
|  |             title, | ||||||
|  |             description, | ||||||
|  |             NULL, | ||||||
|  |             thumbnail, | ||||||
|  |             download | ||||||
|  |         FROM videos_old; | ||||||
|  |         DROP TABLE videos_old; | ||||||
|  |     ''') | ||||||
|  | 
 | ||||||
|  | def upgrade_2_to_3(sql): | ||||||
|  |     ''' | ||||||
|  |     In this version, a column `automark` was added to the channels table, where | ||||||
|  |     you can set channels to automatically mark videos as ignored or downloaded. | ||||||
|  |     ''' | ||||||
|  |     cur = sql.cursor() | ||||||
|  |     cur.execute('ALTER TABLE channels ADD COLUMN automark TEXT') | ||||||
|  | 
 | ||||||
| def upgrade_3_to_4(sql): | def upgrade_3_to_4(sql): | ||||||
|     ''' |     ''' | ||||||
|     In this version, the views column was added. |     In this version, the views column was added. | ||||||
|  | @ -37,44 +75,6 @@ def upgrade_3_to_4(sql): | ||||||
|         DROP TABLE videos_old; |         DROP TABLE videos_old; | ||||||
|     ''') |     ''') | ||||||
| 
 | 
 | ||||||
| def upgrade_2_to_3(sql): |  | ||||||
|     ''' |  | ||||||
|     In this version, a column `automark` was added to the channels table, where |  | ||||||
|     you can set channels to automatically mark videos as ignored or downloaded. |  | ||||||
|     ''' |  | ||||||
|     cur = sql.cursor() |  | ||||||
|     cur.execute('ALTER TABLE channels ADD COLUMN automark TEXT') |  | ||||||
| 
 |  | ||||||
| def upgrade_1_to_2(sql): |  | ||||||
|     ''' |  | ||||||
|     In this version, the duration column was added. |  | ||||||
|     ''' |  | ||||||
|     cur = sql.cursor() |  | ||||||
|     cur.executescript(''' |  | ||||||
|         ALTER TABLE videos RENAME TO videos_old; |  | ||||||
|         CREATE TABLE videos( |  | ||||||
|             id TEXT, |  | ||||||
|             published INT, |  | ||||||
|             author_id TEXT, |  | ||||||
|             title TEXT, |  | ||||||
|             description TEXT, |  | ||||||
|             duration INT, |  | ||||||
|             thumbnail TEXT, |  | ||||||
|             download TEXT |  | ||||||
|         ); |  | ||||||
|         INSERT INTO videos SELECT |  | ||||||
|             id, |  | ||||||
|             published, |  | ||||||
|             author_id, |  | ||||||
|             title, |  | ||||||
|             description, |  | ||||||
|             NULL, |  | ||||||
|             thumbnail, |  | ||||||
|             download |  | ||||||
|         FROM videos_old; |  | ||||||
|         DROP TABLE videos_old; |  | ||||||
|     ''') |  | ||||||
| 
 |  | ||||||
| def upgrade_all(database_filepath): | def upgrade_all(database_filepath): | ||||||
|     ''' |     ''' | ||||||
|     Given the directory containing a phototagger database, apply all of the |     Given the directory containing a phototagger database, apply all of the | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue