using Khaemhat.Data.Migrations; using Khaemhat.Data.Schema; namespace Khaemhat.Data.CompanyDatabase.Migrations; /// Countries, provinces, municipalities, currencies, exchange rates and units of measure (SPEC ยง11.1). [Migration(20261111_011, "create_geography_and_currencies")] public sealed class M20261111_011_CreateGeographyAndCurrencies : IMigration { /// public void Up(ISchemaBuilder schema) { ArgumentNullException.ThrowIfNull(schema); schema.CreateTable("countries", t => { t.Id(); t.String("code", 2).NotNull(); t.String("description", 100).NotNull(); t.Bool("disabled").NotNull().Default(false); t.String("iso3", 3); t.Bool("eu_member").NotNull().Default(false); t.String("vat_prefix", 2); t.String("currency_code", 3); t.DemoColumn(); t.AuditColumns(); t.Unique("ux_countries_code", "code"); }); schema.CreateTable("provinces", t => { t.Id(); t.String("code", 2).NotNull(); t.String("description", 100).NotNull(); t.Bool("disabled").NotNull().Default(false); t.String("region", 60); t.DemoColumn(); t.AuditColumns(); t.Unique("ux_provinces_code", "code"); }); schema.CreateTable("municipalities", t => { t.Id(); t.String("code", 4).NotNull(); t.String("description", 100).NotNull(); t.Bool("disabled").NotNull().Default(false); t.String("province_code", 2).NotNull(); t.String("region", 60); t.String("istat_code", 6); t.String("postal_codes", 400); t.DemoColumn(); t.AuditColumns(); t.Unique("ux_municipalities_code", "code"); t.Index("ix_municipalities_description", "description"); t.Index("ix_municipalities_province_code", "province_code"); }); schema.CreateTable("currencies", t => { t.Id(); t.String("code", 3).NotNull(); t.String("description", 100).NotNull(); t.Bool("disabled").NotNull().Default(false); t.String("symbol", 5); t.Int32("decimals").NotNull(); t.DemoColumn(); t.AuditColumns(); t.Unique("ux_currencies_code", "code"); }); schema.CreateTable("exchange_rates", t => { t.Id(); t.String("currency_code", 3).NotNull(); t.Date("rate_date").NotNull(); t.Decimal("rate").NotNull(); t.String("source", 10).NotNull(); t.AuditColumns(); t.Unique("ux_exchange_rates_currency_code_rate_date", "currency_code", "rate_date"); }); schema.CreateTable("units_of_measure", t => { t.Id(); t.String("code", 10).NotNull(); t.String("description", 100).NotNull(); t.Bool("disabled").NotNull().Default(false); t.Int32("decimals").NotNull(); t.String("e_invoice_code", 10); t.DemoColumn(); t.AuditColumns(); t.Unique("ux_units_of_measure_code", "code"); }); } }