this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

implement basic migration

+42 -25
+1
.gitignore
··· 1 + oudio.db*
+41 -25
src/db/migrate.odin
··· 14 14 15 15 main :: proc() { 16 16 17 - alloc := context.temp_allocator 17 + track: mem.Tracking_Allocator 18 + mem.tracking_allocator_init(&track, context.allocator) 19 + context.allocator = mem.tracking_allocator(&track) 20 + defer { 21 + if len(track.allocation_map) > 0 { 22 + fmt.eprintf("=== %v allocations not freed: ===\n", len(track.allocation_map)) 23 + for _, entry in track.allocation_map { 24 + fmt.eprintf("- %v bytes @ %v\n", entry.size, entry.location) 25 + } 26 + } 27 + if len(track.bad_free_array) > 0 { 28 + fmt.eprintf("=== %v incorrect frees: ===\n", len(track.bad_free_array)) 29 + for entry in track.bad_free_array { 30 + fmt.eprintf("- %p @ %v\n", entry.memory, entry.location) 31 + } 32 + } 33 + mem.tracking_allocator_destroy(&track) 34 + } 18 35 19 - migration_dir, err := filepath.join({#directory, "migrations"}, alloc) 36 + 37 + migration_dir, err := filepath.join({#directory, "migrations"}, context.allocator) 38 + defer delete(migration_dir) 20 39 21 40 assert(err == nil, "Unable to resolve migrations folder path") 22 41 23 - dir_entries, err2 := os.read_all_directory_by_path(migration_dir, alloc) 24 - defer os.file_info_slice_delete(dir_entries, alloc) 42 + dir_entries, err2 := os.read_all_directory_by_path(migration_dir, context.allocator) 43 + defer os.file_info_slice_delete(dir_entries, context.allocator) 25 44 26 45 assert(err2 == nil, "Unable to find migration list from folder") 27 46 28 47 only_sql := slice.filter(dir_entries, proc(x: os.File_Info) -> bool { 29 48 return strings.has_suffix(x.fullpath, ".sql") 30 49 }) 50 + defer delete(only_sql) 31 51 32 52 slice.sort_by(only_sql, proc(a, b: os.File_Info) -> bool { 33 53 return strings.compare(a.fullpath, b.fullpath) < 0 ··· 37 57 38 58 // Apply 39 59 40 - track: mem.Tracking_Allocator 41 - mem.tracking_allocator_init(&track, context.allocator) 42 - 43 - defer { 44 - if len(track.allocation_map) > 0 { 45 - fmt.eprintf("=== %v allocations not freed: ===\n", len(track.allocation_map)) 46 - for _, entry in track.allocation_map { 47 - fmt.eprintf("- %v bytes @ %v\n", entry.size, entry.location) 48 - } 49 - } 50 - if len(track.bad_free_array) > 0 { 51 - fmt.eprintf("=== %v incorrect frees: ===\n", len(track.bad_free_array)) 52 - for entry in track.bad_free_array { 53 - fmt.eprintf("- %p @ %v\n", entry.memory, entry.location) 54 - } 55 - } 56 - mem.tracking_allocator_destroy(&track) 57 - } 58 60 59 61 db: ^sqlite.Connection 60 62 ··· 81 83 82 84 text := string(data) 83 85 84 - fmt.printfln("Migration: %#v", text) 86 + expressions := strings.split(text, ";") 87 + defer delete(expressions) 85 88 89 + trimmed: string 90 + for exp in expressions { 91 + trimmed = strings.trim_space(exp) 92 + if (len(trimmed) == 0) {continue} 86 93 87 - rc := sa.execute(db, text) 88 - assert(rc == .Ok) 94 + fmt.printfln("Expressions: |%#v| \nApplying", trimmed) 95 + 96 + rc := sa.execute(db, trimmed) 97 + assert(rc == .Ok) 98 + 99 + fmt.printfln("Applied successfully") 100 + } 101 + delete(trimmed) 102 + 103 + // rc := sa.execute(db, text) 104 + // assert(rc == .Ok) 89 105 }
vendor/sqlite/libsqlite3.a

This is a binary file and will not be displayed.