ForeignKeyFields out of sync?
usermessage is not user? I think you have problems with your schema. Peewee is not fundamentally broken, if that's what you're suggesting.

Try stackoverflow for questions like these in the future. I am not suggesting peewee is broken. I am just trying to figure what is going on here. 
I being bugged by these issue for quite a while and I have no clue how to figure this out. Maybe I need to fix my schema. But I don't where to start. Is this really because I have a table called user? Your schema is messed up is what I'm trying to suggest. Why would the usermessage's id be the same as the user's id? There's not even a foreign-key to the user table anywhere in your schema.

>because I have a table called user

No. I dumped the database and re-imported it with an ID 1 instead of 9 (after editing the sql file). I don't know if it is a good idea. Maybe it's a patchy solution. 
By saying the schema is messed up you mean that the data was corrupt? Could it be because I made some changes without peewee?
Alternatively, by saying `Your schema is messed up` do you mean I need to change my models in Python?
I am sorry if these are trivial questions for you. This project is the first project I did with peewee so it's not trivial for me. 

At the risk of sounding stupid, I don't know how to give this issue a title.

I have the following database schema:

```python
class UserMessage(BaseModel):
    uuid = UUIDField(index=True)
    link = UUIDField(index=True)
    email = CharField()
    name = CharField()
    message = CharField()
    timestamp = DateTimeField(default=datetime.datetime.utcnow)
    # files attribute is a foriegnkey on UploadedEncryptedFile

    @property
    def full_message(self):

        message = "Hi you got the following message from "
        message += self.name + ":\n"
        message += self.message

        logg.info("found %d files", self.files.count())

        if self.files.count():
            message += "\n\nAttched files:\n"
            url = "{APP_URL}/files/{link}".format(
                    **{"APP_URL": APP_URL, 'link': self.link})

            message += url

        return message


class UploadedEncryptedFile(BaseModel):
    name = CharField()
    file_content = BlobField()
    user = ForeignKeyField(UserMessage, backref='files', on_delete='CASCADE')


class User(BaseModel):
    name = CharField(unique=True)  # adding unique true creates an index
    email = CharField(255)
    password = BlobField(255)
```

When a UserMessage is created it gets the wrong id:
```sql
sqlite> SELECT id from usermessage;
id
9
sqlite> SELECT user_id FROM uploadedencryptedfile;
user_id
1
sqlite>
```

Could peewee doing something wrong here because there is a table called user?
