Mailing List Archive

how to add tables to databes on plugin installation
hi list,

is there any kind of "sane" example how to archive this task? the upgrade
section for the database
is, at least for a dummy like me, not in the slidest useful.

the update section in TracDev desnt help at all since you can'T get behind
the magic that would give you a pointer to a "fresh" creation of a table
for a plugin.

a example with the necessary steps in the IEnvironmentSetupParticipant
functions
would help a lot.

cheers

MArkus

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAJ4osOmqR5mMr1b17jogVL9MYOC6B7EsqZ2MLrrhqiuBPRKR_g%40mail.gmail.com.
Re: how to add tables to databes on plugin installation [ In reply to ]
On Sun, Jan 29, 2023 at 6:12 AM Markus Rosjat <markus.rosjat@gmail.com> wrote:
>
> hi list,
>
> is there any kind of "sane" example how to archive this task? the upgrade section for the database
> is, at least for a dummy like me, not in the slidest useful.
>
> the update section in TracDev desnt help at all since you can'T get behind the magic that would give you a pointer to a "fresh" creation of a table for a plugin.
>
> a example with the necessary steps in the IEnvironmentSetupParticipant functions
> would help a lot.
>
> cheers
>
> MArkus

Have you check out examples for db upgrades in
https://trac.edgewall.org/wiki/TracDev/PluginDevelopment/ExtensionPoints/trac.env.IEnvironmentSetupParticipant#DBupgrades
?

--
Jun Omae <jun66j5@gmail.com> (?? ?)

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAEVLMag7Cjvy6Xf2Xo3TnpbZrg0DJdq0JogK1iS5vMt4Y1bfQw%40mail.gmail.com.
Re: how to add tables to databes on plugin installation [ In reply to ]
hey jun,

yeah i do look at examples, problem for me was it never really triggered
the upgrade so i spend yesterday getting something to work. I have now
something that looks like the example in general but with a lot of hacky
stuff from other plugins like TagsTrac. So i will try to clean up my code
to a version that works in a "cleaner" way i guess.

Cheers

MArkus

Am So., 29. Jan. 2023 um 06:55 Uhr schrieb Jun Omae <jun66j5@gmail.com>:

> On Sun, Jan 29, 2023 at 6:12 AM Markus Rosjat <markus.rosjat@gmail.com>
> wrote:
> >
> > hi list,
> >
> > is there any kind of "sane" example how to archive this task? the
> upgrade section for the database
> > is, at least for a dummy like me, not in the slidest useful.
> >
> > the update section in TracDev desnt help at all since you can'T get
> behind the magic that would give you a pointer to a "fresh" creation of a
> table for a plugin.
> >
> > a example with the necessary steps in the IEnvironmentSetupParticipant
> functions
> > would help a lot.
> >
> > cheers
> >
> > MArkus
>
> Have you check out examples for db upgrades in
>
> https://trac.edgewall.org/wiki/TracDev/PluginDevelopment/ExtensionPoints/trac.env.IEnvironmentSetupParticipant#DBupgrades
> ?
>
> --
> Jun Omae <jun66j5@gmail.com> (?? ?)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Trac Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to trac-users+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/trac-users/CAEVLMag7Cjvy6Xf2Xo3TnpbZrg0DJdq0JogK1iS5vMt4Y1bfQw%40mail.gmail.com
> .
>

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAJ4osO%3DYPstv9sg7zHDkjB-aps3XcifKiwCiSTkrRh%3DcZgHnMA%40mail.gmail.com.
Re: how to add tables to databes on plugin installation [ In reply to ]
btw I see a lot of Table definitions and i figure the key is like the
primary key for the table but does trac implementation of table and column
has the concept of a foreign key or is this something we need to check in
the code ?

for example the ticket tables, ticket table has an id and related table
have a column ticket that seems to be the ref to the tickek id but i
dont see any definition of a foreign key so i there seems to be no
integrity checks? This in turn defeats the
whole purpose of a releational database.

cheers

Markus

Am So., 29. Jan. 2023 um 09:33 Uhr schrieb Markus Rosjat <
markus.rosjat@gmail.com>:

> hey jun,
>
> yeah i do look at examples, problem for me was it never really triggered
> the upgrade so i spend yesterday getting something to work. I have now
> something that looks like the example in general but with a lot of hacky
> stuff from other plugins like TagsTrac. So i will try to clean up my code
> to a version that works in a "cleaner" way i guess.
>
> Cheers
>
> MArkus
>
> Am So., 29. Jan. 2023 um 06:55 Uhr schrieb Jun Omae <jun66j5@gmail.com>:
>
>> On Sun, Jan 29, 2023 at 6:12 AM Markus Rosjat <markus.rosjat@gmail.com>
>> wrote:
>> >
>> > hi list,
>> >
>> > is there any kind of "sane" example how to archive this task? the
>> upgrade section for the database
>> > is, at least for a dummy like me, not in the slidest useful.
>> >
>> > the update section in TracDev desnt help at all since you can'T get
>> behind the magic that would give you a pointer to a "fresh" creation of a
>> table for a plugin.
>> >
>> > a example with the necessary steps in the IEnvironmentSetupParticipant
>> functions
>> > would help a lot.
>> >
>> > cheers
>> >
>> > MArkus
>>
>> Have you check out examples for db upgrades in
>>
>> https://trac.edgewall.org/wiki/TracDev/PluginDevelopment/ExtensionPoints/trac.env.IEnvironmentSetupParticipant#DBupgrades
>> ?
>>
>> --
>> Jun Omae <jun66j5@gmail.com> (?? ?)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Trac Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to trac-users+unsubscribe@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/trac-users/CAEVLMag7Cjvy6Xf2Xo3TnpbZrg0DJdq0JogK1iS5vMt4Y1bfQw%40mail.gmail.com
>> .
>>
>

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAJ4osO%3Dn99YQ-6nwdZVKNCEni%3DOtwKPfy-2tE%3DN6WFMFp4AgBg%40mail.gmail.com.
Re: how to add tables to databes on plugin installation [ In reply to ]
another strange behaviour, at least in my opinion, is that if i define a
column to be auto_increment i expect the insert statements to take care of
the incrementation of the column if i omit it,

for example I define a table

Table("ttmsd_webhook_types", key=("id"))[
Column("id", type="int",auto_increment=True),
Column("name", type="text"),],

then I expect to pass data to insert_into_table to work with a tuple like

("ttmsd_webhook_types",
("name"),
(("MS Teams",),
("Discord",))
)
but it doesnt, it give me a IndexError: tuple index out of range error and
i need to define my tuple like

("ttmsd_webhook_types",
("id","name"),
((1,"MS Teams",),
(2,"Discord",))
)
for initial data that should be fine since i know what i add but if i want
to update my types later on I always need to get the count of the id
sequence first to not mess up.

Or do I simply miss stuff here ???

Cheers

MArkus


Am So., 29. Jan. 2023 um 09:52 Uhr schrieb Markus Rosjat <
markus.rosjat@gmail.com>:

> btw I see a lot of Table definitions and i figure the key is like the
> primary key for the table but does trac implementation of table and column
> has the concept of a foreign key or is this something we need to check in
> the code ?
>
> for example the ticket tables, ticket table has an id and related table
> have a column ticket that seems to be the ref to the tickek id but i
> dont see any definition of a foreign key so i there seems to be no
> integrity checks? This in turn defeats the
> whole purpose of a releational database.
>
> cheers
>
> Markus
>
> Am So., 29. Jan. 2023 um 09:33 Uhr schrieb Markus Rosjat <
> markus.rosjat@gmail.com>:
>
>> hey jun,
>>
>> yeah i do look at examples, problem for me was it never really triggered
>> the upgrade so i spend yesterday getting something to work. I have now
>> something that looks like the example in general but with a lot of hacky
>> stuff from other plugins like TagsTrac. So i will try to clean up my code
>> to a version that works in a "cleaner" way i guess.
>>
>> Cheers
>>
>> MArkus
>>
>> Am So., 29. Jan. 2023 um 06:55 Uhr schrieb Jun Omae <jun66j5@gmail.com>:
>>
>>> On Sun, Jan 29, 2023 at 6:12 AM Markus Rosjat <markus.rosjat@gmail.com>
>>> wrote:
>>> >
>>> > hi list,
>>> >
>>> > is there any kind of "sane" example how to archive this task? the
>>> upgrade section for the database
>>> > is, at least for a dummy like me, not in the slidest useful.
>>> >
>>> > the update section in TracDev desnt help at all since you can'T get
>>> behind the magic that would give you a pointer to a "fresh" creation of a
>>> table for a plugin.
>>> >
>>> > a example with the necessary steps in the IEnvironmentSetupParticipant
>>> functions
>>> > would help a lot.
>>> >
>>> > cheers
>>> >
>>> > MArkus
>>>
>>> Have you check out examples for db upgrades in
>>>
>>> https://trac.edgewall.org/wiki/TracDev/PluginDevelopment/ExtensionPoints/trac.env.IEnvironmentSetupParticipant#DBupgrades
>>> ?
>>>
>>> --
>>> Jun Omae <jun66j5@gmail.com> (?? ?)
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Trac Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to trac-users+unsubscribe@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/trac-users/CAEVLMag7Cjvy6Xf2Xo3TnpbZrg0DJdq0JogK1iS5vMt4Y1bfQw%40mail.gmail.com
>>> .
>>>
>>

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAJ4osOm%2BnV30mgopiORKFEtAWownkU234QDe7Oxa-tSdncuhmA%40mail.gmail.com.
Re: how to add tables to databes on plugin installation [ In reply to ]
On Sun, Jan 29, 2023 at 8:26 PM Markus Rosjat <markus.rosjat@gmail.com> wrote:
> then I expect to pass data to insert_into_table to work with a tuple like
>
> ("ttmsd_webhook_types",
> ("name"),
> (("MS Teams",),
> ("Discord",))
> )

The columns should be a list or a tuple.

- ("name"),
+ ["name"],

> for initial data that should be fine since i know what i add but if i want to update my types later on I always need to get the count of the id sequence first to not mess up.

If you need other operations than simple inserting rows, use directly
queries such SELECT/INSERT/UPDATE/DELETE using
self.env.db_transaction() and cursor.execute().

--
Jun Omae <jun66j5@gmail.com> (?? ?)

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAEVLMahR1TA%3DfV0ZoQp2CQW0w062w3XaKqt%3Dy29oHH097V4ZRg%40mail.gmail.com.
Re: how to add tables to databes on plugin installation [ In reply to ]
i will try that and i saw the plain sql string approach too but i got some
basic stuff working at the moment.

cheers

Markus

Am So., 29. Jan. 2023 um 12:40 Uhr schrieb Jun Omae <jun66j5@gmail.com>:

> On Sun, Jan 29, 2023 at 8:26 PM Markus Rosjat <markus.rosjat@gmail.com>
> wrote:
> > then I expect to pass data to insert_into_table to work with a tuple like
> >
> > ("ttmsd_webhook_types",
> > ("name"),
> > (("MS Teams",),
> > ("Discord",))
> > )
>
> The columns should be a list or a tuple.
>
> - ("name"),
> + ["name"],
>
> > for initial data that should be fine since i know what i add but if i
> want to update my types later on I always need to get the count of the id
> sequence first to not mess up.
>
> If you need other operations than simple inserting rows, use directly
> queries such SELECT/INSERT/UPDATE/DELETE using
> self.env.db_transaction() and cursor.execute().
>
> --
> Jun Omae <jun66j5@gmail.com> (?? ?)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Trac Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to trac-users+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/trac-users/CAEVLMahR1TA%3DfV0ZoQp2CQW0w062w3XaKqt%3Dy29oHH097V4ZRg%40mail.gmail.com
> .
>

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAJ4osOnLKOMT8bmO8686mWEXOPxqZ0JDc%2BjVCA%3Dm_ZXwE%3DuFSA%40mail.gmail.com.