import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('basic_info', '0013_alter_customer_options'),
        ('stock', '0005_stockchangedetail_consume_fields'),
    ]

    operations = [
        migrations.SeparateDatabaseAndState(
            database_operations=[
                migrations.RunSQL(
                    sql="ALTER TABLE IF EXISTS stock_purchaseorder RENAME TO business_purchaseorder;",
                    reverse_sql="ALTER TABLE IF EXISTS business_purchaseorder RENAME TO stock_purchaseorder;",
                ),
            ],
            state_operations=[
                migrations.CreateModel(
                    name='PurchaseOrder',
                    fields=[
                        ('id', models.BigAutoField(primary_key=True, serialize=False)),
                        ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                        ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                        ('order_date', models.DateField(verbose_name='订单日期')),
                        ('total_amount', models.DecimalField(decimal_places=2, max_digits=15, verbose_name='总金额')),
                        ('remarks', models.TextField(blank=True, null=True, verbose_name='备注')),
                        ('merchant', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='purchase_orders', to='basic_info.merchant', verbose_name='所属商户')),
                        ('supplier', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='purchase_orders', to='basic_info.supplier', verbose_name='供应商')),
                    ],
                    options={
                        'verbose_name': '采购单',
                        'verbose_name_plural': '采购单',
                    },
                ),
            ],
        ),
    ]

