Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nadine Fisch 159 posts 429 karma points
    May 20, 2018 @ 12:46
    Nadine Fisch
    0

    extend Database and save data in a new table

    Hi,

    I have to create a reminder, so I think I have to extend the database (create a new table with reminder dates and intervals). I would like to save the data in a new table and create a job to read the data on a interval.

    Could you give me an example how can I save the data in the database or is there a better approach as the create a new table?

    Thank you in advance, Nadine

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    May 20, 2018 @ 14:45
    Nik
    1

    Hi Nadine,

    This blog post (although slightly out of date) is a great example on how to extend the Umbraco database using Migrations and PetaPoco. PetaPoco is included in Umbraco and Migrations are the technology that Umbraco uses to help deploy changes to it's database. We can utilise the same approach with your query.

    https://cultiv.nl/blog/using-umbraco-migrations-to-deploy-changes/

    I say it is slightly out of date as some of the commands have changed slightly but the basic principles are correct.

    Hope it helps :-)

    Nik

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    May 28, 2018 @ 12:15
    Michael Latouche
    1

    Hi Nadine,

    You might also have a look to the Fluidity package, which (in short) allows creating extra data and also generates automatically all you need to manage it from the back-office.

    The package is available there: https://our.umbraco.org/projects/backoffice-extensions/fluidity/

    Hope it helps!

    With kind regards,

    Michaël.

  • Nadine Fisch 159 posts 429 karma points
    May 29, 2018 @ 12:11
    Nadine Fisch
    0

    Hi,

    thank you for your advice, I am using Umbraco version 7.3.0, I am not able to use this plugin, because of an installation error.

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    May 29, 2018 @ 12:30
    Michael Latouche
    0

    Hi Nadine,

    Too bad, from the package page it seems indeed that it is available from version7.6...

    An opportunity to upgrade maybe ;-) ;-) ?

    Cheers,

    Michael.

  • Nadine Fisch 159 posts 429 karma points
    May 29, 2018 @ 12:32
    Nadine Fisch
    0

    :D yes.. I'll give it a try...cross your fingers :D

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    May 29, 2018 @ 12:34
    Michael Latouche
    1

    Will do! Good luck :-)!

  • Nadine Fisch 159 posts 429 karma points
    May 29, 2018 @ 20:54
    Nadine Fisch
    0

    Upgrade to the current version seems not not to work. I have to upgrade all minor Releases... this is a lot of work for the real Time I have.

    Are there any other suggestions? Please keep in mind, that I am not able to rebuild the solution, because of not having a local environment and Umbraco Version 7.3.0:(

    i would at least create the tables on the db server on my own and create methods for crud-actions, if this is allowed in Umbraco and if there are methods to do this ?? :) do I Need to recompile the Source Code with petaPoco?

    Sorry for my noobish questions:)

  • Comment author was deleted

    May 31, 2018 @ 10:18

    Hey Nadine, if you are on that version of Umbraco try https://github.com/TimGeyssens/UIOMatic

    If combined with https://github.com/TimGeyssens/MCFly you won't even need to code to be able to CRUD a custom db table

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    May 31, 2018 @ 09:51
    Michael Latouche
    0

    Hi Nadine,

    Sorry to hear it did not work with the upgrade...

    I am afraid I cannot help you much more on this topic, as I have never done something similar myself :-S I hope someone else can pick up the thread...

    Cheers,

    Michaël.

  • Nadine Fisch 159 posts 429 karma points
    Jun 01, 2018 @ 08:06
    Nadine Fisch
    0

    Ok, I am using PetaPoco now and I've managed to compile my code with just restarting the IIS Server ;) My controller and view files are in the App_Code -Folder now. I created a startup class that create the table if it doesnt exist.
    But there is still a problem. I don't see the table in my database, altough I see this message in the log, so I am really confused. I thought maybe there could be a permission problem?

    Umbraco.Core.Persistence.Database - New table 'tablename'  was created
    
  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Jun 01, 2018 @ 08:11
    Michael Latouche
    0

    Hi Nadine,

    Could you maybe post the part of the code where you create the table? It might help understand what is going wrong. I find it strange that the name of the table mentioned in the log is "tablename", if everything went well, I guess it should normally be the actual name of the table you created.

    Cheers,

    Michaël.

  • Nadine Fisch 159 posts 429 karma points
    Jun 01, 2018 @ 08:17
    Nadine Fisch
    0

    Oh, I just make my tablename anonymous :)

    public class Startup : ApplicationEventHandler
    {
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            DatabaseContext ctx = ApplicationContext.Current.DatabaseContext;
            DatabaseSchemaHelper dbSchema = new DatabaseSchemaHelper(ctx.Database, ApplicationContext.Current.ProfilingLogger.Logger, ctx.SqlSyntax);
    
            if (!dbSchema.TableExist("tablename")) dbSchema.CreateTable<MyModulClassName>(false);
    
        }
    }
    

    In my poco-model-class the tablename is declared like this

       [TableName("tablename")]
    
  • Nadine Fisch 159 posts 429 karma points
    Jun 01, 2018 @ 08:27
    Nadine Fisch
    0

    Yeah :D The table is created correctly in the database...I see it. Maybe I overlooked it - I don't know !! I am really,really sorry for wasting your time Michael ! :-)

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Jun 01, 2018 @ 08:30
    Michael Latouche
    1

    Hihi, good news, I'm glad it's working :-) !

    No problem, it did not take me too long to write the last post ;-)

    Have a nice week-end!

    Cheers,

    Michaël.

Please Sign in or register to post replies

Write your reply to:

Draft