Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

99 строки
2.7 KiB

  1. //
  2. // File.swift
  3. //
  4. //
  5. // Created by Bill Ryckman on 4/26/23.
  6. //
  7. import Vapor
  8. import Fluent
  9. struct CreateFuelEntry: AsyncMigration {
  10. func prepare(on database: Database) async throws {
  11. try await database.schema("fuel_entries")
  12. .id()
  13. .field("timestamp", .datetime)
  14. .field("user_id", .string)
  15. .field("gps_location", .string)
  16. .field("image", .string)
  17. .field("product", .string)
  18. .field("make", .string)
  19. .field("model", .string)
  20. .field("serial_number", .string)
  21. .field("tank_id", .string)
  22. .field("fuel_amount", .double)
  23. .field("fuel_type", .string)
  24. .field("is_override", .bool)
  25. .create()
  26. }
  27. func revert(on database: Database) async throws {
  28. try await database.schema("fuel_entries").delete()
  29. }
  30. }
  31. struct AddLatitudeAndLongitudeAndRemoveGpsLocationAndImage: AsyncMigration {
  32. func prepare(on database: Database) async throws {
  33. try await database.schema("fuel_entries")
  34. .field("latitude", .double)
  35. .field("longitude", .double)
  36. .deleteField("gps_location")
  37. .deleteField("image")
  38. .update()
  39. }
  40. func revert(on database: Database) async throws {
  41. try await database.schema("fuel_entries")
  42. .deleteField("latitude")
  43. .deleteField("longitude")
  44. .field("gps_location", .string)
  45. .field("image", .string)
  46. .update()
  47. }
  48. }
  49. struct AddImageBackIn: AsyncMigration {
  50. func prepare(on database: Database) async throws {
  51. try await database.schema("fuel_entries")
  52. .field("image", .string)
  53. .update()
  54. }
  55. func revert(on database: Database) async throws {
  56. try await database.schema("fuel_entries")
  57. .deleteField("image")
  58. .update()
  59. }
  60. }
  61. struct StoreImageDataInDatabase: AsyncMigration {
  62. func prepare(on database: Database) async throws {
  63. try await database.schema("fuel_entries")
  64. .deleteField("image")
  65. .field("image", .data)
  66. .update()
  67. }
  68. func revert(on database: Database) async throws {
  69. try await database.schema("fuel_entries")
  70. .deleteField("image")
  71. .field("image", .string)
  72. .update()
  73. }
  74. }
  75. struct AddDownloadedBool: AsyncMigration {
  76. func prepare(on database: Database) async throws {
  77. try await database.schema("fuel_entries")
  78. .field("downloaded", .bool)
  79. .update()
  80. }
  81. func revert(on database: Database) async throws {
  82. try await database.schema("fuel_entries")
  83. .deleteField("downloaded")
  84. .update()
  85. }
  86. }