由于Django不支持复合主键,因此为关联(或联结)表实现模型的最佳实践是什么?
我有一张将<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<propertyFile>${project.build.directory}/unpack/liquibase.properties</propertyFile>
<outputChangeLogFile>${project.build.directory}/liquibase-outputChangeLog.xml</outputChangeLogFile>
<changeLogFile>${project.build.directory}/liquibase-outputChangeLog.xml</changeLogFile>
<diffTypes>tables, views, columns, indexes, foreignkeys, primarykeys, uniqueconstraints, data</diffTypes>
</configuration>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate4</artifactId>
<version>3.5</version>
</dependency>
<!-- ojdbc6.jar example -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.1</version>
</dependency>
<!-- ojdbc7.jar example -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-change-log</id>
<phase>generate-resources</phase>
<goals>
<goal>generateChangeLog</goal>
</goals>
</execution>
<execution>
<id>sync-sql-log</id>
<phase>process-resources</phase>
<goals>
<goal>changelogSync</goal>
</goals>
</execution>
<execution>
<id>generate-sql-log</id>
<phase>generate-resources</phase>
<goals>
<goal>updateSQL</goal>
</goals>
</execution>
</executions>
</plugin>
映射到user_id
的表,该表对形成一个复合主键。 user_type_id
和user
字段最初都是user_type
类,但是解释器给出了使用ForeignKey
的提示。我没有收到以下代码的警告。这是实现表的正确方法吗?
OneToOneField