Django migrate:不创建表

2024-05-06

经过一些错误后,我删除了数据库,删除了所有迁移文件(我留下了init.py)。 现在,当我跑步时

python migrate.py makemigrations   // It creates migrations correctly
python migrate.py migrate          // It outputs "app.0001_initial OK"

但绝对NO table(与我的应用程序相关)是created。只有那些与 django 相关的才是。 在迁移表中,我的应用程序迁移被标记为已完成,但正如我所说,没有创建任何表,这非常令人不快。

这是我的迁移文件的摘录:

# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-02-18 21:59
from __future__ import unicode_literals

import colorful.fields
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Client',
            fields=[
                ('id', models.AutoField(db_column='idtblclients', primary_key=True, serialize=False)),
                ('genre1', models.CharField(blank=True, max_length=10)),
            ('prenom1', models.CharField(blank=True, max_length=45)),
            ('nom1', models.CharField(blank=True, max_length=45)),
            ('genre2', models.CharField(blank=True, max_length=10)),
            ('prenom2', models.CharField(blank=True, max_length=45)),
            ('nom2', models.CharField(blank=True, max_length=45)),
            ('courriel', models.CharField(blank=True, max_length=45)),
            ('langue', models.CharField(blank=True, max_length=1)),
            ('numtel1', models.CharField(blank=True, db_column='NumTel1', max_length=20)),
            ('numtel2', models.CharField(blank=True, db_column='NumTel2', max_length=20)),
            ('numcivique', models.CharField(blank=True, db_column='NumCivique', max_length=15)),
            ('rue', models.CharField(blank=True, db_column='Rue', max_length=45)),
            ('ville', models.CharField(blank=True, db_column='Ville', max_length=45)),
            ('codepostal', models.CharField(blank=True, db_column='CodePostal', max_length=45)),
            ('timestamp', models.DateTimeField(blank=True, db_column='Timestamp', null=True)),
            ('zone', models.CharField(blank=True, db_column='Zone', max_length=45)),
        ],
        options={
            'db_table': 'tblclients',
            'managed': False,
        },
    ),
....

您知道如何解决它吗?


python manage.py migrate --fake APPNAME zero

这将使您的迁移变得虚假。 现在您可以运行迁移脚本

python manage.py migrate APPNAME

将创建表 你解决了你的问题..干杯!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Django migrate:不创建表 的相关文章

随机推荐