Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

55 linhas
1.4 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. }