Lucky
So, yes the current index on file_id is what I created
Lucky
Maybe I should rollback a backup and wait for migrations.... ...
Lucky
But than, I never rolled back a backup, so I'll try to get it running again
Alexander
I think it may be an index for a foreign key column. The Sticker entity has file_id attribute as a primary key, and I can guess that StickerPack entity has some attribute which defined as Required(Sticker) or Optional(Sticker). For such a column there is a foreign key to sticker table, and it is recommended to create an index as well. So Pony creates such indexes automatically. The name of the index includes the table name and looks like idx_stickerpack_attrname. You need to drop such index, and Pony will create new index with name idx_pack_attrname
Lucky
I removed any primary key form file_id in that database
Lucky
Lucky
Alexander
I think that the error is not with primary key, but with additional indexes
Alexander
Some index which belongs to former stickerpack table and starts with idx_stickerpack_
Alexander
It should start with idx_pack_ now
Alexander
You can rename Pack back to StickerPack until migrations isnot released and all should work again
Lucky
Okey, I just dropped all Constraints and Indexes I clould find
Lucky
Nope.
Alexander
Did you see indexes with names started with idx_?
Lucky
Micaiah
Micaiah
that's pretty sweet
Lucky
Finally fixed that database
Lucky
Finally fixed that database
And @StickerTagBot as well as getstickers.me is up again.
(I really need to add a static served replacement for downtime like that.)
Lucky
Thanks for your support @akozlovsky !!!
Lucky
Lucky
Basically the problem was PrimaryKey() not allowing index=True
Alexander
Time to do backup ;)
Lucky
Lucky
But I have no idea how I would import that, so I just solved the issue instead :D
Ngalim
Did ponyorm only allow one large model.py files 🤔
Or can we separate to few small files?
Alexander
Yes, you can split it to many files
Alexander
yes
# models1.py
db = Database()
class X(db.Entity):
a = Set("Y") # syntax1
b = Set(lambda: db.Z) # syntax 2
# models2.py
from models1 import db
class Y(db.Entity):
c = Required("X")
# models3.py
from models1 import db
class Z(db.Entity):
d = Optional(lambda: db.X)
Alexander
when writing queries you can do this
from models1 import X
select(x for x in X if ...)
or that:
from models1 import db
select(x for x in db.X if ...)
Alexander
If you split entities between several files, then you need to not forget to import all of that files
Micaiah
yeah so they all get mapped
Alexander
yes
Alexander
Also, sometimes it may be convenient to define entities inside a function:
def define_entities(db):
class Person(db.Entity):
name = Required(str)
db = Database()
define_entities(db)
db.bind(...)
db.generate_mapping(...)
with db_session:
select(p for p in db.Person)
Ngalim
Ngalim
is it correct?
I got error `pony.orm.core.ERDiagramError: Entity definition Training was not found`
Alexander
Well, you wrote trainings = orm.Set('Training'), but entity Training is not found :)
Ngalim
Ngalim
sorry
Ngalim
looks like i need coffee
Lucky
The online editor's Cascade delete setting still is broken, False becomes True in the python code export.
Lucky
(Video uploading)
Lucky
Alexey
Lucky
Apparently a != default check
Lucky
Also still a bug:
Lucky
If I edit a text field and click in the editor window, it is not safed
Lucky
Lucky
As you see, you have to click another field first, else it isn't stored.
Alexey
Lucky
fixed
The unfocus one, or the Cascade delete?
Alexey
Alexey
both
Lucky
both, ok :D
Alexey
pls confirm
Lucky
Still missing size=64 for ints, and sql_default='NOW()' for datetimes
Alexey
Lucky
focus ✅
Lucky
cascade delete 🚫
Both default (False) and False result in packs = Set('Pack').
Setting it to False should result in
packs = Set('Pack', cascade_delete=False)
🚫
Setting it to False should result in
packs = Set('Pack')
✅
Alexey
you're right
stsouko
Hello!
stsouko
class Molecule(db.Entity):
_table_ = (schema, 'molecule')
id = PrimaryKey(int, auto=True)
date = Required(datetime, default=datetime.utcnow())
data = Required(Json)
fear = Required(str, unique=True)
fingerprint = Required(str, sql_type='bit(%s)' % (2 ** FP_SIZE))
children = Set('Molecule', cascade_delete=True)
parent = Optional('Molecule')
stsouko
is it possible delete parent relation without delete data?
stsouko
e.g. return parent to None
Alexander
Yes, why not:
m = Molecule[id]
m.parent = None
stsouko
Thank You!
Alexander
Sure
Alexey
Alexey
depending on the attribute type
Alexey
if the other side is Required then default is True
if the other side is Optional then default is False
Lucky
Oh. Okey, that makes sense.
Lucky
Is that reflected corretly on the python side?
Alexey
should be
Lucky
Huh, cool
Alexey