Altering database structure on Smartface application upgrade - smartface.io

What is the best approach to alter an existing database on Smartface application upgrade?
New version of my app has slightly different database structure (new columns were added).
When upgraded happened GUI-desined datasets are new (with new columns) while existing database is old (without those columns).
Existing database contains user data meaning replacing it with an empty one is not an option.
The following code is not working (column is not added):
Data.execute("ALTER TABLE TableSettings ADD COLUMN NewColumn TEXT;");
Data.execute("UPDATE TableSettings SET NewColumn = 'test is fine';");
Data.DatasetSettings.refresh();
Pls share some ideas how to solve the problem.

During upgrade, if the structure of table is same and has keepDataOnUpdate flag true, data will be kept.
Method1
You may use new table to work with. Copy data from exiting to new one and delete records inside old one. Do not remove old table.
Method2
You may alter table as you do now. For future versions, add some checks to database to avoid re-adding of column by script. Use dynamic dataset to work with that table. Static datasets are tightly bound to table meta during publish; With static dataset you cannot use your new columns.
In future versions of Smartface (expected 4.5 or 4.6) database management will be given to users providing more control on what is on database and more control about update procedures.

Related

Sorrm how to add a column to an existing table

I need to add a new column to an existing table, I know I could create a new model and migrate the data over but that wouldn't be idle any other way?
Unfortunately the only other way is to use some administration tool for your database to manually update the schema to match the one for the new model.

SSAS Date dimension schema generation fails

I am following the standard steps to create date dimension in SSAS here-
The generate schema option fails! this is the message from schema generation wizard
create failed for table myusername.dimdate
I think the problem is that the table should be created for a different schema. If below is the selected option for schema generation -
Subject Area
Data source view: ABC PROJ
**Schema: ABC_PROJ(WXY1230)**
Data will be preserved
Time table will be populated
Shouldn't the Dimdate table be created ABC_PROF(WXY1230).Dimdate and not under myusername.DimDate?
Any idea what could be missing? I have been struggling with this for hours now.
Thanks for any help.
I think that is an unfortunate bug in the SSAS generated date dimension. When you generate the dimension you are using your Windows credentials and SSAS uses the default schema for the user context it was provided. I believe your user has a default schema of myusername on that database, which is what is causing the date dimesion to be created there.
If you create the dimension, you have the option to generate the schema now or generate it later. If you choose to generate it later and go through the Schema Generation Wizard, you eventually see a screen that shows the Owning Schema.
. There is no mechanism to change it even though you can see it (At least not in SSDT. I don't have BIDS on any of my machines). You are not the only person to run into this issue.
So you have a few options as a workaround:
Use a different account that has a default schema that is the correct schema where you want to place your date table.
Create the table under your default user and populate it. Then alter the table in SQL Server to move it to the correct schema. Then update your DSV.
Don't use SSAS to generate your date dimension. There are plenty of scripts out there that create great date dimensions. Here's an example. This means you will need to create the dimension and build the hierarchy yourself, but it's not that much work compared to the time you've spent trying to fix this issue.

Is it possible to create table templates in Filemaker?

I'm using Filemaker Pro 12 and I was wondering if there is a way of creating a template for tables. There are a number of fields I'm placing in my tables that are identical utility-fields like modification time-stamp, active/inactive flags, etc. I was hoping there was a way that I could define the skeleton of each table somehow instead of having to manually add these identical fields every time.
If you are using the Advanced version, you can copy&paste fields among tables/files.
Using the regular version, you can import records from your "default" table and specify [New Table...] as the target table. This will recreate the source table's structure in the target file. The source table does not have to contain any records for this to work.
To expand a little bit on michael-hor257k's answer, if you're using FileMaker Pro Advanced, a good practice is to create a "Default" table that has your core utility fields. When you want to make a new table in Manage Database, instead:
Highlight the Default table,
Copy & Paste the table, then
Rename the new table.

How to apply new changes without dropping current data in the db.(Playframework evaluations)

I'm using play 2.2.1 with scala. And I have a managing database evaluations. When I run my application with changes on the database, it'll drop all my datas.
At this moment evaluationplugin = disabled is comment in. If I comment out, it does not apply my changes.
For example. I have a users table and there are id, f_name, l_name
User
id f_name l_name
1. khazo rasp
And I want to add age field to this table without losing data. I've added this field in scala files.It works properly. I'm assuming I need to write script in 1.sql for some alter command, but I don't want to write script.
How to apply new changes without dropping current data in the db. I've read this documentation. Thanks in advance.
I've added this field in scala files
In slick (you have the tag play-slick), you can specify a default value in your Table
See the documentation here, under Tables:
Default[T](defaultValue: T)
Specify a default value for inserting data the table without this column. This information is only used for creating DDL statements so that the database can fill in the missing information.
I am not sure if it gets translated to ALTER statement if the table already exists . You will have to test it.

Crystal: Autoupdating table names in database expert

It is more of an annoyance rather than real issue: when in Crystal reports you change the data source to one with different name (and do all the linking old columns to new columns) all the table names in Field explorer and (obviously) in formulas are changed. But the Database expert still shows the old table/view name!
Let me show this on example: Lets say I change TABLE_1 with column EQUIPMENT to VIEW_1 with column UNIT. Via the datasource location I can do the substitution and link old column EQUIPMENT to new one - UNIT.
But when I check either Datasource location or database expert it will be still showing old TABLE_1 (if you check the columns in the link tab you will notice that the TABLE_1 has now column UNIT instead of EQUIPMENT).
This can be quite annoying and frankly bit dangerous, especially if you return to report after a longer while. Is there somewhere a setting that allows to autoupdate table names in the database expert?
When you create the report it will create tables and each table will be linked to a datasource table. So the report table will have a name and datasource , which might be the same. When you change the datasource the datasource of the table will be updated but the report table name will remain the same. Think about this name as an alias. It might differs from th datasource name if you use the same table multiple times
I don't think there is auto update option in crystal reports but one thing you can do is to use Verify Database option under Database tab whenever you update the tables.
You need to manually edit table names in Database expert, there's no automatic way (and like Lan already answered, it is generally not possible).