MDriven administrative database tables
No edit summary
No edit summary
Line 1: Line 1:
==== New 2024-02-18; Use MDrivenServer to create to the admin tables instead of manually as described below ====
This is described in this video: https://youtu.be/BmmoAFjaQtc
==== Manual process ====
When you create a database from a model these administrative tables will be added automatically for you.
When you create a database from a model these administrative tables will be added automatically for you.



Revision as of 20:23, 18 February 2024

New 2024-02-18; Use MDrivenServer to create to the admin tables instead of manually as described below

This is described in this video: https://youtu.be/BmmoAFjaQtc

Manual process

When you create a database from a model these administrative tables will be added automatically for you.

But when reversing an existing database to a model - and then wanting to use the model just like any another MDriven Model you may find that you need to add these manually.

Below is the script and explanation of what the table is for:

Table name PostgreSQL
ECO_ID This is the cursor of the default internal key assigned to objects saved with the default persistence mapper.

This table only has 1 row holding the next free identity for a new object

CREATE TABLE [dbo].[ECO_ID](

[PK] [int] NOT NULL,

[BOLD_ID] [int] NOT NULL,

CONSTRAINT [PK_ECO_ID] PRIMARY KEY CLUSTERED

(

[PK] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

CREATE TABLE eco_id (

    pk SERIAL primary key,

    bold_id INT NOT NULL

);

ECO_ORMAPPING This holds a text-blob with the OR-mapping in MDrivenFormat (xml). MDriven reads this upon evolve of database to figure out what we has changed compared to the current model.

After successfull evolve MDriven writes the updated OR-mapping to this column. The Table only holds 1 row

CREATE TABLE [dbo].[ECO_ORMAPPING](

[ID] [int] NOT NULL,

[ECO_ORMAPPING] [ntext] NOT NULL,

PRIMARY KEY CLUSTERED

(

[ID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

CREATE TABLE eco_ormapping (

id SERIAL PRIMARY KEY, eco_ormapping TEXT NOT NULL );

ECO_TABLES This table has one row per table that MDriven has created or taken ownership of in your database. CREATE TABLE [dbo].[ECO_TABLES](

[TABLENAME] [nvarchar](255) NOT NULL

) ON [PRIMARY]

GO

CREATE TABLE eco_tables (

tablename VARCHAR(255) NOT NULL );

ECO_TYPE This table holds the class names from your model along with an integer number unique to that type. If MDriven is instructed to write many types to the same table (OR-Parent-Mapping) MDriven figures out the runtime type by lookin the ECO_TYPE column of such a table - and the number will match a number in the ECO_TYPE table. CREATE TABLE [dbo].[ECO_TYPE](

[ECO_TYPE] [smallint] NOT NULL,

[CLASSNAME] [nvarchar](255) NOT NULL,

PRIMARY KEY CLUSTERED

(

[ECO_TYPE] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO

CREATE TABLE eco_type (

eco_type SMALLINT NOT NULL, classname VARCHAR(255) NOT NULL, PRIMARY KEY (eco_type) );

This page was edited 40 days ago on 03/18/2024. What links here